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
150
Problems with get_gridResponseObject()
posted

Hi everyone !!!

I'm having a problem with WebDataGrid. I'm using 13.1 and in DataFiltered client side event I'm trying to obtain a parameter that I put in server side on Page_Load event.

Page_Load event (server side)

GridView1.CustomAJAXResponse.AdditionalProperties.Add("rowCount", -1);

Javascript Client Side

function GridView1_DataFiltered(sender, eventArgs) {
   ///<param name="sender" type="Infragistics.Web.UI.WebDataGrid"></param>
   ///<param name="eventArgs" type="Infragistics.Web.UI.DataFilteredArgs"></param>

   //Add code to handle your event here.
   var rowCount = eventArgs.get_gridResponseObject().AdditionalProperties.rowCount;
   if (rowCount != -1) {
      $("#lblTotal").text("Total: " + rowCount + " Registro(s)");
   }
}

Until yesterday, I was trying to fix another problem I had with paging behavior but, after fix it, I encountered with the filtering problem.

Thanks a lot !!!!

Gustavo.-

Parents
No Data
Reply
  • 10685
    Offline posted

    Hello Gustavo,

    Thank you for posting in our forums.

     

    Regarding the use of CustomAJAXResponse.AdditionalProperties you could refer to these resources:

    storing node data for ajax postback

    How do I reset the css styling of a row during an ajax post-back

     

    As example – a scenario of using AdditionalPropperties:

    ”So let's assume we have a bunch of cells which style we want to change. 

    1) We form by some logic on the server side the array of these cells. For example,  GridRecordItem[] cells.

    2) We add "addresses" of these cells to customAjaxResponse. There are different ways to do that - using indexes (which I wouldn't recommend because if something in your code sorts the values it can cause problems) or idpairs for rows, I just used row.DataKey in the following code:

    int i = 0;
    foreach (GridRecordItem cell in cells)
    {
        this.WebDataGrid1.CustomAJAXResponse.AdditionalProperties.Add("rowKey" + i.ToString(),
                                                                                                        cell.Row.DataKey);
        this.WebDataGrid1.CustomAJAXResponse.AdditionalProperties.Add("columnKey" + i.ToString(),
                                                                                                        cell.Column.Key);
    i++;
    }
    this.WebDataGrid1.CustomAJAXResponse.AdditionalProperties.Add("Count", i);

    Please note, that for this you must have columnKeys assigned.

    3) In AJAX postback handler on the client side we set our styles.

    function WebDataGrid1_Grid_AJAXResponse(sender, e) {
        var grid = $find('<%= this.WebDataGrid1.ClientID %>');
        var properties = e.get_customResponseObject().AdditionalProperties;
        for (var i = 0; i < properties.Count; i++) {
            var rowKey = properties["rowKey" + i];
            var columnKey = properties["columnKey" + i];
            var row = grid.get_rows().get_rowFromKey(rowKey);
            if (row != null) {
                var cell = row.get_cellByColumnKey(columnKey);
                if (cell != null) {
                   cell.get_element().className = "YourCSSName"; 
                }

            }
        }
    }

     

    Please let me know how these suggestions work for you and if you require further assistance.

Children