Hello,
We are using a remote data source with igGrid (Infragistics version 2013.2) in an ASP.NET application.
The behavior we are after is that when the user enters a filter value that doesn't exist in the grid, our server web method (that the grid automatically calls on remote sorting) will return an empty row set (but a full column set) so that the grid can still keep its auto generated columns but have no rows. Currently we are building the JSON string on the server and pushing it back to the client via HTTP response. How would the JSON string need to look in order to bind the columns but no rows in igGrid?
Since our data sets are user generated and we cannot know what columns will be included until runtime we are using autogeneratecolumns : true in igGrid.
An example of our JSON with rows:
{"totalRowCount":1,"data": [{"ColA" : "A"}, {"ColB" : "B"} ]}
How do we return that JSON if it had 0 rows?
Hello Ivaylo,
I do not manually run an ajax call to get the data source for the grid. Instead I have provided the grid with an URL to my web method on the server so that the grid itself can trigger an ajax call to that web method whenever the user interacts with the grid through filter, sort or paging. Dues to this I have limited control over the ajax call in itself. The only thing I can do is control what the response from the web method is. Is there no way of passing a list of columns back and keep autogeneratecolumns to true?
Otherwise I suppose I have to fetch the databinding event on the grid and manually check the data source and if it's empty I need to modify the autogeneratecolumns property and set it to false? Could you please provide an example of this?
Hello Johan,
In order to set the column only and no data in the grid, it is possible to set the columns to autoGenerateColumns =false and using an AJAX call manually define the columns to be rendered. Using this approach the igGrid will render as an empty and only the columns will be defined. You could afterwards use the dataSourceUrl in order to link the grid to the data already available (and enable autoGenerateColumns=true if required).
Please let me know if you have more questions regarding this!