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

How to load data using datasource

3 Answers 741 Views
ListView (Mobile)
This is a migrated thread and some comments may be shown as answers.
Andrea
Top achievements
Rank 1
Andrea asked on 21 Dec 2016, 05:02 PM

Hello, i would like to make list to fill its data from an URL, but I am not able to do that, i tried to follow documentation but I have only found example of loading local data.

That is working, but i would like to use ajax datasource, http://dojo.telerik.com/@andrea/uvanE

That is the json data that correspond to the execution of the MVC controller I have server side: http://dojo.telerik.com/@andrea/uvanE/2

that is my try to use the remote data http://dojo.telerik.com/@andrea/uvanE/3

the json data have been generated by the following server code, and i do not know if it is in the correct format that the list expect

[Authorize]
        [HttpPost]
        public ActionResult GetShippers([DataSourceRequest] DataSourceRequest request)
        {
            
            return Json(new string[] { "A", "B", "C" }.ToDataSourceResult(request));
        }

3 Answers, 1 is accepted

Sort by
0
Andrea
Top achievements
Rank 1
answered on 22 Dec 2016, 06:00 PM

Well, finally is working, but the problem it's in the parsing of the result created by your ToDataSourceResult extension method.

http://dojo.telerik.com/@andrea/uvanE/3

To let my server controller work i had to change the return value as follows:

[Authorize]
[HttpPost]
public ActionResult GetShippers([DataSourceRequest] DataSourceRequest request)
{
   return Json(new string[] { "A", "B", "C" }.ToDataSourceResult(request).Data);
}

 

0
Alex Hajigeorgieva
Telerik team
answered on 23 Dec 2016, 10:22 AM
Hi Andrea,

You should add the schema configuration to the Kendo UI Data Source. This will allow it to parse correctly,
i.e:

schema: {
 data: "Data",
 total: "Total",
 errors: "Errors"
},

I have updated it using the original server response in the first post:
({"Data":["A","B","C"],"Total":3,"AggregateResults":null,"Errors":null})

http://dojo.telerik.com/UQARE

If you wish to bind directly to action methods, we have a project referenced at:

http://docs.telerik.com/kendo-ui/controls/data-management/grid/how-to/Editing/grid-bound-to-asp-net-mvc-action-methods---crud-operations

Finally, the Kendo UI schema API reference is available at:

http://docs.telerik.com/kendo-ui/api/javascript/data/datasource#configuration-schema

Let me know if you need more assistance.

Regards,
Alex Hajigeorgieva
Telerik by Progress
Try our brand new, jQuery-free Angular 2 components built from ground-up which deliver the business app essential building blocks - a grid component, data (charts) and form elements.
0
Andrea
Top achievements
Rank 1
answered on 23 Dec 2016, 02:28 PM

Thank you, that will let me use the mvc controllers as I always did when i used the grid.

 

Best regards

Andrea

Tags
ListView (Mobile)
Asked by
Andrea
Top achievements
Rank 1
Answers by
Andrea
Top achievements
Rank 1
Alex Hajigeorgieva
Telerik team
Share this question
or