User Profile & Activity

Hans Kristian Member
Page
of 69
Posted: August 1, 2012 10:46 PM
Hello,

Honestly, I haven’t try and have no experience about how to using Excel VBA module.

Could you tell me more information about your scenario that you want to apply with WebCombo?
For example, what kind option that you want to select? Or what are you trying do to with the selected option next?

And could you help / guide me to know how to integrated WebCombo to the Excel VBA module?
So perhaps I can help you to find work around for your current scenario.

Meanwhile, for your information, for select the option or the value to WebCombo, you could use SetText method or set the value in Page_Load.

Thank you.

Regards,
Hans.

Hello,

I’m glad to hear that you have found the solution for your project’s scenario.
Should you have further question, please do not hesitate to contact us.

Thank you.

Regards,
Hans.
Posted: August 1, 2012 6:28 AM

Hello,

Basically the type of data source and method parameter doesn’t take any affect to my code. Could you provide a simple sample that replicate your issue? So i can help you investigate this issue further more.

I made a another simple to demonstrate how to delete multiple row using button and or context menu. In this sample, I use batch update to True.
I use AcceptAllChanges() function to apply all changes without click “Accept All Changes” button in WebGrid.

Here this snippet code in WebButton’s OnClientClick client side event:

function WebButton1_OnClientClick(controlId, parameter) {    var WebButton1 = ISGetObject(controlId);    var WebGrid1 = ISGetObject("WebGrid1");
    var checkedRows = WebGrid1.RootTable.GetCheckedRows();
    for (var i = 0; i < checkedRows.length; i++) {
        WebGrid1.RootTable.ToRowObject(checkedRows[i]).Delete();
    }
    WebGrid1.AcceptAllChanges();
    return true;
}

And I set a validation in WebGrid’s OnAddPendingChanges() client side event:

function WebGrid1_OnAddPendingChanges(controlId, table, rowChange) {
    var WebGrid1 = ISGetObject("WebGrid1");
    if (rowChange.RowState == "Deleted") {
        window.setTimeout(function () { WebGrid1.AcceptAllChanges(); }, 10);
    }
    return true;
}

Please have review on my sample. Thank you.

Regards,
Hans.

Hello,

Could you please provide me a simple sample that replicate your issue?
So I can help you to investigate your issue on my end.

Thank you.

Regards,
Hans.

Hello,

Thank you for your information.

I made a simple sample to demonstrate how to hide and show WebGrid column from client side.
I bind the WebGrid to access data source (Northwind.mdb database & Shippers table).
In my sample, I try to hide\show Phone column using WebButton’s OnClientClick client side event.
Here’s the snippet code in OnClientClick:

function WebButton1_OnClientClick(controlId, parameter) {    var WebButton1 = ISGetObject(controlId);
    var WebGrid1 = ISGetObject("WebGrid1");
    if (!WebGrid1.RootTable.Columns.GetNamedItem("Phone").Visible) {
        WebGrid1.RootTable.Columns.GetNamedItem("Phone").Visible = true;
        WebGrid1.RootTable.Columns.GetNamedItem("Phone").Show();
    } else {
        WebGrid1.RootTable.Columns.GetNamedItem("Phone").Visible = false;
        WebGrid1.RootTable.Columns.GetNamedItem("Phone").HideFromView();
    }
    return true;
}

However, if you want to make any changes to your Webgrid’s column, for example adding new columns, the structure is changed and could not be modified easily without fullpostback.

In my humble opinion, I recommended you to handle all your WebGrid’s changes using fullpostback event. So you could easier to handle all your WebGrid’s changes.

I attached my sample as well. Please have review on my sample.

Thank you.

Regards,
Hans.

Posted: July 31, 2012 5:58 AM

Hello,

That supposedly doesn’t affect my code.

Could you provide me more information about your code/your scenario that you want to achieve?
Or could you provide me a simple sample that replicate your issue?

Perhaps I can help you to investigate your issue on my end.

Thank you.

Regards,
Hans.

Hello,

Yes, you could. You should set “ChildRowEmptyAction” property to “HideChildContent”.
Then set a validation in OnAfterResponseProcess() client side event.
Here’s the snippet code in OnAfterResponseProcess():
function WebGrid1_OnAfterResponseProcess(controlId, actionName, lastRequestObject, xmlResponseObject) {    var WebGrid1 = ISGetObject(controlId);
    if (actionName == "DeleteRow") {
        var childRowsLenght = lastRequestObject.GetParentRow().GetChildRows().length;
        // if there is no child row any more
        if (childRowsLenght == 0) {
            // we need to refresh the WebGrid to apply the ChildRowEmptyAction property
            WebGrid1.Refresh();
        }
    }
    return true;
}

Also “RestoreExpandedChildRows” property to “True” and “RestoreRowSelection” to “All”.

Hope this helps.

Regards,
Hans.

Posted: July 30, 2012 3:52 AM
Hello,

I made a simple sample that perhaps similar with your scenario.
I bind WebGrid to access data source control (Northwind.mdb and Shippers table).

I attached my sample. Please have review on my sample and let me hear your response.

Thank you.

Regards,
Hans.

Hello,

Thank you for you code and I’m sorry for any inconveniences this issue has caused you.

I made a simple sample based on code that you provide to me. I bind the WebGrid to access data source (Northwind.mdb database & Shippers table).

1) Then I try to remove the columns for couple times, but I’m sorry, it always works fine on my end. Could you provide me more detail about your current scenario? So that I can investigate this issue further more.

2) You could use RefreshAll() WebGrid’s method in OnColumnResize function, to post back after you resize the column.
In my sample, I use a couple of HiddenField control to save the new width. You could use another way to use the new width, for example session variable.
In OnColumnResize client side event, I save the new width. Here the snippet code:
function WebGrid1_OnColumnResize(controlId, tblName, column, width) {    var WebGrid1 = ISGetObject(controlId);
    var ShipperIDColumn = document.getElementById("ShipperIDColumn");
    var CompanyNameColumn = document.getElementById("CompanyNameColumn");
    var PhoneColumn = document.getElementById("PhoneColumn");
    var ShipperIDWidth = document.getElementById("ShipperIDWidth");
    var CompanyNameWidth = document.getElementById("CompanyNameWidth");
    var PhoneWidth = document.getElementById("PhoneWidth");
    // To save the new width
    if (column.DataMember == ShipperIDColumn.value) {
        ShipperIDWidth.value = width;
    }
    else if (column.DataMember == CompanyNameColumn.value) {
        CompanyNameWidth.value = width;
    }
    else {
        PhoneWidth.value = width;
    }
    // To post back
    WebGrid1.RefreshAll();
    return true;
}

Then I made some validation in InitializeColumn server side event, to apply the new width. Here the snippet code:

protected void WebGrid1_InitializeColumn(object sender, ISNet.WebUI.WebGrid.ColumnEventArgs e)
{
    // To set ShipperID Column
    if (ShipperIDColumn.Value == e.Column.DataMember && ShipperIDWidth.Value != "")
    {
        string newWidth = ShipperIDWidth.Value;
        int intNewWitdh = Int32.Parse(newWidth);
        e.Column.Width = System.Web.UI.WebControls.Unit.Pixel(intNewWitdh);
    }
    // To set CompanyName Column
    else if (CompanyNameColumn.Value == e.Column.DataMember && CompanyNameWidth.Value != "")
    {
        string newWidth = CompanyNameWidth.Value;
        int intNewWitdh = Int32.Parse(newWidth);
        e.Column.Width = System.Web.UI.WebControls.Unit.Pixel(intNewWitdh);
    }
    // To set Phone Column
    else if (PhoneColumn.Value == e.Column.DataMember && PhoneWidth.Value != "")
    {
        string newWidth = PhoneWidth.Value;
        int intNewWitdh = Int32.Parse(newWidth);
        e.Column.Width = System.Web.UI.WebControls.Unit.Pixel(intNewWitdh);
    }
}

I attached my sample as well. Please have a review on my sample and let me hear your response.

Thank you.

Regards,
Hans.

Posted: July 26, 2012 11:59 PM

Hello,

I’m glad to hear that you have achieved your goal.
Should you have further question, please do not hesitate to contact us.

Thank you.

Regards,
Hans.

All times are GMT -5. The time now is 4:25 PM.
Previous Next