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

[Solved] Passing extra data with GridModel

3 Answers 94 Views
Grid
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Brian Solli
Top achievements
Rank 1
Brian Solli asked on 30 May 2011, 12:58 PM
We are using the Grid with Ajax calls to server. These calls returns View(new GridModel()) of some sorts

In some operations we want to pass on more data than what the GridModel accepts (more than Data, Total), however it seems like the GridAction attribute will filter away extra Json data. Is there a clean way to do this? What will we lose if we removed the GridAction attribute?

I've looked at the thread under, but that doesn't quite meet our criterias since it only covers errors.
http://www.telerik.com/community/forums/aspnet-mvc/grid/how-to-return-error-information-to-grid-in-ajax-editing-mode.aspx

3 Answers, 1 is accepted

Sort by
0
Atanas Korchev
Telerik team
answered on 31 May 2011, 09:30 AM
Hello Brian Solli,

 The GridAction attribute performs the data related operations - paging, sorting, grouping etc. If you remove it you will have to perform those by yourself. Even if you do this the grid currently does not expose all the data received from the server. It only exposes the total and data fields. 

Regards,
Atanas Korchev
the Telerik team
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 Public Issue Tracking system and vote to affect the priority of the items
0
Brian Solli
Top achievements
Rank 1
answered on 31 May 2011, 12:39 PM
Ok, so you confirm that there is no easy way to pass extra data through the GridModel or manual Json if we don't want to lose the build in functionality.

I looked at some other threads and this:

http://www.telerik.com/community/forums/aspnet-mvc/grid/control-delete-edit-errors-in-ajax-mode.aspx


solves some our issues, but the issue with adding ModelState.Errors in the delete action not showing, is still there. Is that something that is being looked at?
Also exposing errors to the end user via the existing OnError event or some other event sounds like a nice feature.

0
Atanas Korchev
Telerik team
answered on 31 May 2011, 01:12 PM
Hello Brian Solli,

 ModelState errors are displayed by showing the corresponding validators. In delete mode there are no validators enabled hence model state errors are not shown.

We are now raising the OnError event when there are modelstate errors. You can handle it and display them appropriately. This online example shows how:

function Grid_onError(args) {
    if (args.textStatus == "modelstateerror" && args.modelState) {
        var message = "Errors:\n";
        $.each(args.modelState, function (key, value) {
            if ('errors' in value) {
                $.each(value.errors, function() {
                    message += this + "\n";
                });
            }
        });
        args.preventDefault();
        alert(message);
    }
}

I confirm that there is currently no way to submit custom data from the server to the browser using the action method which provides data for the grid.

You can return custom result by omitting the GridAction attribute and doing custom binding but there is no way to retrieve that data once the grid gets it.

Regards,
Atanas Korchev
the Telerik team
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 Public Issue Tracking system and vote to affect the priority of the items
Tags
Grid
Asked by
Brian Solli
Top achievements
Rank 1
Answers by
Atanas Korchev
Telerik team
Brian Solli
Top achievements
Rank 1
Share this question
or