Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
115
Init empty Grid by MVC Wrapper
posted

Hi!

I tried to migrate an ASP.Net MVC project from 2015.2 to 2016.1.
I initialize my controls by the MVC wrapper, because its very easy.
I don't set a DataSource or DataSourceUrl, because in the most cases i set them dynamically in JavaScript afterwards (for example i add a url-get-parameter in reference to an other object).

This behaviour is no more possible in 2016.1. I always get an exception with undefined or null property "Records".

You can test this by your sample project. Just remove the line with "DataSourceUrl" in "Views\Grid\aspnet-mvc-helper.cshtml" and call the page in your browser.
In 2015.2 you get an empty Grid, in 2016.1 you'll get an exception.

It would be great if you can give me a workaround to use them.
I also would like to see an alternative for sending a parameter in the databind-method to the controller by adding a get-parameter to the DataSourceUrl.

Parents
No Data
Reply
  • 3995
    Verified Answer
    Offline posted

    Hello Michael,

    You can set .ResponseDataKey(null) if you don't specify data source initially.

    But then afterwards just before applying the data to the grid you need to specify its responseDataKey. (By default the MVC wrapper set this value to be "Records")

    For example:

    $("#Grid1").igGrid("option", "responseDataKey", "Records");

    $("#Grid1").igGrid("option", "dataSource", "http://localhost:4616/iggrid/getdata");

Children