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

Grid doesn't display when remote binding

4 Answers 69 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Johannes
Top achievements
Rank 1
Veteran
Johannes asked on 17 Mar 2017, 05:32 AM

I am currently evaluating Telerik at the moment and we are currently trying to get our application to use the Grid widget to display a list of "Terms". The grid works semi-nicely when we parse a Model to the partial view and then use the Model with the grid. Model is below;

 

    public class Term
    {
        [Key]
        [DatabaseGenerated(DatabaseGeneratedOption.Identity)]
        public int TermID { get; set; }
        [Required]
        public string TermName { get; set; }
        public string TermDescription { get; set; }
        public bool Preferred { get; set; }
    }

 

The problem is that there can be an unlimited amount of "Terms" so we have tried to use remote binding. However, when we use remote binding, the Grid widget doesn't show up at all. The method in the controller gets the data, and the browser seems to retrieve the json (according to Fiddler).

Controller Method

        public ActionResult _TermTable([DataSourceRequest]DataSourceRequest request)
        {
            using (IVContext db = new IVContext())
            {
                return Json(db.Terms.ToDataSourceResult(request),JsonRequestBehavior.AllowGet);
            }
        }

Partial View

@(Html.Kendo().Grid<DemoSpace.Models.Term>()
    .Name("grid")
    .Columns(columns =>
    {
        columns.Bound(p => p.TermID);
        columns.Bound(p => p.TermName);
        columns.Bound(p => p.TermDescription);
        columns.Bound(p => p.Preferred);
    })
    .DataSource(dataSource => dataSource
        .Ajax()
        .PageSize(20)
        .ServerOperation(true)
        .Read(read => read.Action("_TermTable", "Admin"))
     )
)

I know that I am going to be missing something obvious, but I just can't see it.

 

Any and all help is appreciated.

 

4 Answers, 1 is accepted

Sort by
0
Accepted
Konstantin Dikov
Telerik team
answered on 20 Mar 2017, 03:15 PM
Hi Johannes,

The configuration and the action method seems correct. Nevertheless, you could take a look at our help topic for the AJAX binding:
You could also inspect the browser`s console and see if there are any JavaScript errors that could help us pinpoint the root of the problem.

Finally, you could go through the following troubleshooting section and see if this applies to your case:

Regards,
Konstantin Dikov
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 visualization (charts) and form elements.
0
Johannes
Top achievements
Rank 1
Veteran
answered on 21 Mar 2017, 04:41 AM

Thanks for the response.

I have noticed that I am using HttpGet instead of HttpPost. I have attempted to make it use Post but it says that it can not find the action. The Get still seems to return the right data though. I have attached the response as a PNG.

I have also got the Microsoft.jQuery.Unobtrusive.Ajax NuGet package in my application. Would this somehow interfere with the widget working?

 

 

 

0
Johannes
Top achievements
Rank 1
Veteran
answered on 21 Mar 2017, 04:56 AM

[quote]Johannes said:

...

I have also got the Microsoft.jQuery.Unobtrusive.Ajax NuGet package in my application. Would this somehow interfere with the widget working?

[/quote]

 

This does not interfere as I took it out and attempted to make it work. Still nothing.

0
Johannes
Top achievements
Rank 1
Veteran
answered on 21 Mar 2017, 06:55 AM
The problem I was having was that I was loading it in a partialview that was loaded after another partialview. Now I have put it straight into the first partialview, it seems to work. No idea why this would be the case but it now works.
Tags
Grid
Asked by
Johannes
Top achievements
Rank 1
Veteran
Answers by
Konstantin Dikov
Telerik team
Johannes
Top achievements
Rank 1
Veteran
Share this question
or