This is a migrated thread and some comments may be shown as answers.

MVC Grid - Get values from other pages?

4 Answers 166 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Greg
Top achievements
Rank 1
Greg asked on 23 Feb 2016, 07:01 PM

Is it possible to get some or all of the values from subsequent pages in the grid?

For example:

The user is on page one or three. I would like to get all of the values for a particular column from the grid. Even those values not shown in the grid (pages 2 & 3).

4 Answers, 1 is accepted

Sort by
0
Dimiter Madjarov
Telerik team
answered on 24 Feb 2016, 11:55 AM

Hello Greg,

This is possible only if the values are existing in the Grid's dataSource. For example if Ajax dataSource is used, the server operations should be disabled. This means that all of the items will be retrieved at once and could be accessed by the application.
E.g.

.DataSource(dataSource => dataSource
   .Ajax()
   .PageSize(20)
   .ServerOperation(false)
)

Regards,
Dimiter Madjarov
Telerik
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
0
Greg
Top achievements
Rank 1
answered on 24 Feb 2016, 12:11 PM

Thanks for the reply.

Hmm, I'm not sure if that's an option for us. Some of our lists can grow quite large and the performance implications of trying to load all the data at once might be catastrophic.

Is there a way to request from the server additional pages without refreshing the UI? The example in the documentation for the "dataSource.query" does not appear to work and throws an exception around "slice".

0
Dimiter Madjarov
Telerik team
answered on 25 Feb 2016, 11:55 AM

Hello Greg,

I am not able to reproduce the mentioned bug in the query documentation page. Nevertheless using this method is not suitable for the current case, as the queried items will be bound to the Grid. There is no suitable workaround that we could suggest for the scenario.

Regards,
Dimiter Madjarov
Telerik
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
0
Greg
Top achievements
Rank 1
answered on 25 Feb 2016, 06:13 PM

I found a solution to my problem.The goal was to be able to get a complete list of all records that might be in the grid. A 'select all' without actually having all the items in the grid. What was key is to be able to apply all the same filters, sorts and groups to the data that are currently applied to the grid. Also it was very important that we maintain the current status of the grid. The example code below provides the functionality required.

        var grid = $("#mygrid").data("kendoGrid");

        var parameterMap = grid.dataSource.transport.parameterMap;
        var data = parameterMap({ sort: grid.dataSource.sort(), filter: grid.dataSource.filter(), group: grid.dataSource.group() });
        var extraParams = { sort: data.sort, filter: data.filter, group: data.group, varX: x, varY: y, varZ: z};

        $.ajax({
            url: _relativePath + "/MyController/MyMethod", //Same controller and method called by the grid definition.
            data: extraParams,
            type: "POST",
            dataType: "json",
            async: false,
            success: function(result) {
                alert('Success!');
            },
            error: function (e) {
            }
        });

Thanks.

Tags
Grid
Asked by
Greg
Top achievements
Rank 1
Answers by
Dimiter Madjarov
Telerik team
Greg
Top achievements
Rank 1
Share this question
or