Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
665
Unable to set cell value client side
posted

Hi there

I am trying to keep track of modified rows of the WebDataGrid. The following discussion http://ko.infragistics.com/community/forums/t/67651.aspx implies that IsDirty() method of GridRecord is not going to work. So to keep track of the modified values I have added a hidden data bound column to the grid – bound to ‘Status’ property of the record and implemented EditingClientEvents-CellValueChanging event handler on the client side. The event handler sets a value in the hidden column. On the server side, when a "Save" button is pressed on a form, I iterate trough the WebDataGrid rows, check the value of the ‘Status’ property and save the records that are added or modified.

The event handler for  CellValueChanging looks like this:

function updateEntityState_OnChange(sender, eventArgs) {

     for (i = 0; i < eventArgs._cell._row._element.cells.length; i++)

    {

        if (sender._columns._items[i]._key == 'Status') {           

             var status = eventArgs._cell._row._element.cells[i].firstChild.nodeValue;

             if (status == null) {

                eventArgs._cell._row._element.cells[i].firstChild.nodeValue = 2/*Added*/;

            }

            else if (status == 0/*Unchanged*/) {

                eventArgs._cell._row._element.cells[i].firstChild.nodeValue = 1/*Modified*/;

            }

            break;

        }

    }

}

 

The implementation above does not work. When I step though the code in the debugger everything looks fine but the when I check the row on a server a value in “Status” column is always 0.

 I have three questions here:

  1. What is a correct way of setting value of another cell from client side code?
  2. The use of underscored methods/properties in my code does not look right. When I tried to use more ‘civilized’ function call notation, (similar to http://ko.infragistics.com/community/forums/t/44515.aspx) I am getting Object does not implement method errors. Am I missing some Infgagistics library/script that have cell.get_value() and cell.set_value() defined?
  3. Is there any way of making use of IsDirty() method of GridRecord object on a server side?

 

Thank you

 

Boris

 

Parents
No Data
Reply
  • 15320
    Offline posted

    Hello boris_qbf,

    First of all you should note that since hidden fields do not render on the client, hence their values are not accessible there and could not be modified. Also using of private properties/methods in the client events is not recommended. I would suggest you in the current scenario if you want to check whether there are changes made to the grid and based on that update the value of the hidden field, to handle RowUpdating server side event. For instance the following code checks if changes are made to the "Name" column in the grid and updates the "Status" column value and also makes this column visible:

    protected void WebDataGrid1_RowUpdating(object sender, Infragistics.Web.UI.GridControls.RowUpdatingEventArgs e)

    {

    DataTable dt = populateGrid();

    if (e.Values["Name"] != e.OldValues["Name"])

    {

    e.Row.Items[2].Column.Hidden = false;

    dt.Rows[e.Row.Index]["Status"] = "modified";

    WebDataGrid1.DataSource = dt;

    WebDataGrid1.DataBind();

    }

    }

    Attached is a sample with similar scenario for your reference.

    If you have any further questions, feel free to contact me.

    Sincerely,

    Tsanna

    SetCellValueClient.zip
Children