We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

Query: Grid-loading,paging,checkbox column

Hello
I have some questions.
1:
    when  loading data by apiController ,i set parameters is  empty when initializing Grid,after finished loading i query the data according to the conditions ,click the column header to sort after the data has loaded ,then grid data will be cleared
2:
    How do real paging for grid, such as according to pagesize loaded, rather than all the data is loaded. 
3:
    If I add a checkbox column to the grid, after the page jump back and forth, the selected checkbox will disappear

1 Reply

MS Madhu Sudhanan P Syncfusion Team May 8, 2014 12:04 PM UTC

Hi wz,

 

Please find the response.

 

Query #1: “ when  loading data by apiController ,i set parameters is  empty when initializing Grid, after finished loading i query the data according to the conditions ,click the column header to sort after the data has loaded ,then grid data will be cleared”

 

Based on your requirement, we have created a simple MVC Grid sample in which the grid is populated with the data from the Web API 2 OData Controller and the same can be downloaded from the below location.

 

Sample Location: F116270.zip

 

In the above sample, initially the grid is loaded with data from APIController. Then using the textbox value, grid data will be changed by querying the APIController. Please refer the below code snippet.

 

 

@(Html.EJ().Grid<WebAPI_CSharp.Models.Order>("MasterGrid")

    .Datasource("/odata/Orders")

    . . . .

    .ClientSideEvents(e => e.ActionBegin("begin"))

    .Render())

 

@(Html.EJ().Button("Filter")

    . . .

    .ClientSideEvents(eve => eve.Click("filter"))

    .Render())

 

function filter(args) {

                var gridObj = $("#MasterGrid").data("ejGrid");

                var dropObj = $("#dropdown").data("ejDropDownList");

                var columnName = dropObj.getSelectedItem();

                var inputdata = $("#val").val();

                var filterdata = columnName == "CustomerID" ? "'" + inputdata + "'" : parseInt(inputdata);

                //add $filter params using query based textbox value and dropdown

                query = ej.Query().addParams("$filter", columnName + " eq " + filterdata);

                gridObj.refreshGridContent();//Refersh grid content

            }

 

            function begin(args) {

                //Assign the generated query to the grid query property in actionBegin event

                if (args.requestType == "refresh")

                    args.model.query = query != undefined ? query : args.model.query;

            }

 

 

Query #2: “How do real paging for grid, such as according to pagesize loaded, rather than all the data is loaded.”

 

Normally with paging enabled, the data will be requested from the apiController according to the pagesize rather than the whole data. When the Offline property of the DataManager is set to true, the data will be fetched from the server only once; further actions will be performed on the client side.

 

The offline property of the datamanager can be set as follow. Please refer the below code snippet.

 

 

@(Html.EJ().Grid<WebAPI_CSharp.Models.Order>("MasterGrid")

    .Datasource(d=>d.Url("/odata/Orders").Offline(true));

    . . . .

    . . . .

    .Render())

 

 

 

 

Query #3: “If I add a checkbox column to the grid, after the page jump back and forth, the selected checkbox will disappear”

 

We are unable to reproduce this issue. Could you please provide us more information (Screenshot or Sample) regarding the issue?. The information provided will be more helpful for us to analyze your requirement and provide you solution as early as possible.

 

Please let us know if you have any queries.

 

Regards,

Madhu Sudhanan. P


Loader.
Live Chat Icon For mobile
Up arrow icon