MVC Grid - Get values from other pages?

5 posts, 0 answers
  1. Greg
    Greg avatar
    18 posts
    Member since:
    Nov 2012

    Posted 23 Feb Link to this post

    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).

  2. Dimiter Madjarov
    Admin
    Dimiter Madjarov avatar
    2153 posts

    Posted 24 Feb Link to this post

    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
  3. UI for ASP.NET MVC is VS 2017 Ready
  4. Greg
    Greg avatar
    18 posts
    Member since:
    Nov 2012

    Posted 24 Feb in reply to Dimiter Madjarov Link to this post

    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".

  5. Dimiter Madjarov
    Admin
    Dimiter Madjarov avatar
    2153 posts

    Posted 25 Feb Link to this post

    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
  6. Greg
    Greg avatar
    18 posts
    Member since:
    Nov 2012

    Posted 25 Feb in reply to Dimiter Madjarov Link to this post

    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.

Back to Top
UI for ASP.NET MVC is VS 2017 Ready