I'm trying to integrate iggrid from IgniteUI(TypeScript) to my IIS based application. I have custom API and I want to implement remote paging. My API has different names of parameters and returns items in content and total number in headers. I also need to add some headers to request.
Can I somehow do request by myself and just feed all necessary data to iggrid or do I really need to use iggrid to ask for data directly?
Hello Mohammed,
Thank you for posting in our community.
By design when you are using Infragistics ASP.NET MVC wrapper it will handle remote paging automatically for you. If you are implementing your own remote service, in order to properly initialize and render the pager. your service must specify both the responseDataKey(grid option) and the recordCountKey(paging option). The recordCountKey member tells the Paging widget how many records in total are in the backend. the responseDataKey specifies which property in the response contains the resulting data.
More details regarding configuring remote features manually can be found here. This topic will guide you through the process manually handling igGrid remote features remote requests and sending back a response in a JSON format that they can understand. Please have a look at the "handling Remote Paging" section and let me know if you need any further assistance with this matter.
Hi Vasya,
Thanks for the response. So this is my setup:
When the user clicks next or selects a page number to navigate to I am firing a pageIndexChanging event which contains the page number the user wants to see. I am retrieving the correct contents in the correct format and overwriting the existing dataSource with this new one, but it does not update on the grid.
It just shows the selected page number and the grid is empty and does not show any contents. Seems like I somehow need to update the items on the table.
I also tried re-rendering the IgGrid- it updated the contents but the page number was not changing, it was highlighted as page number 1 no matter which page I selected. The contents of the grid were changing, though.
Could you please help me work around this.
Thanks.
By design if remote Paging is used the igGrid will make a remote request. Since the dataSource url in your scenario is not set this request will not be successful and respectively the data, which the igGrid is expecting, is not going to be loaded correctly. My suggestion for achieving your requirements is handling urlParamsEncoding event of the data source, which is fired before the URL parameters are encoded. The idea is to populate the custom properties, which your API service is expecting (page size, total records count, page index etc.) in the URL and return the resulting data.
var myUrlParamsEncoding = function (item, params) { alert("myUrlParamsEncoding"); } var ds; $(window).load(function () { var url = "http://services.odata.org/OData/OData.svc/Products?$format=json&$callback=?"; ds = new $.ig.DataSource({ callback: render, dataSource: url, schema: { fields: [{ name: "Name" }, { name: "Price" }, { name: "Rating" }], searchField: "d" }, responseDataKey: "d", responseDataType: "jsonp", urlParamsEncoding: myUrlParamsEncoding }); ds.dataBind(); });
This approach will avoid rebinding the igGrid on every page change and will not interfere with the default data binding cycle of the grid.
Please let me know if you need any further assistance with this matter.
Hi,
What I ended up doing is set a custom responseDataKey and total records key, firing a custom event every time a page change or sort happens and when I get a response I provide the object as the dataSourceObject and then call dataBind
hi
Can you please provide a sample how you acheived this having the same senario.
Thanks
Hello Ameur,
A sample demonstrating how to handle remote features is available in our online samples browser here.
In this sample Remote features are handled on the server side in the GridRemoteDataAction in the Controller. When a specific action is applied, for example paging, a remote request is send to the server with additional information stored in the query string. On the server side , the feature specific parameters are extracted from the Query String and the related data operations are applied to the data. Once the data is fully processed the result is returned in JSON format to the client.
Please have a look at this sample and I believe it will help you achieve your requirement.