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

Hierarchical grid, client grid templates with javascript for server side error handling?

2 Answers 60 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Spirent
Top achievements
Rank 1
Spirent asked on 30 Oct 2014, 07:22 PM
I have a grid with 2 child grids defined as client templates. I want to handle server side validation as described here: http://blogs.telerik.com/kendoui/posts/13-08-29/handling-server-side-validation-errors-in-your-kendo-ui-grid but I am unsure of how to have the javascript for each client grid as each grid has a different ID and will need a different errors list.

2 Answers, 1 is accepted

Sort by
0
Alexander Popov
Telerik team
answered on 03 Nov 2014, 03:19 PM
Hi,

Since the Grids are initialized through a template there is no good way of using different event handlers. You could however, use a proxy function to pass the Grid's ID, which can be used from within the handler to identify it. For example: 
<script id="template" type="text/kendo-tmpl">
    @(Html.Kendo().Grid<Kendo.Mvc.Examples.Models.OrderViewModel>()
            .Name("grid_#=EmployeeID#")
            .Columns(columns =>
            {
                columns.Bound(o => o.ShipCountry).Width(110);
                columns.Bound(o => o.ShipAddress);
            })
            .DataSource(dataSource => dataSource
                .Ajax()
                .Events(e=>e.Error(@<text>function(e) { onError(e,"grid_#=EmployeeID#") }</text>))
                .PageSize(10)
                .Read(read => read.Action("HierarchyBinding_Orders", "Grid", new { employeeID = "#=EmployeeID#" }))
            )
            .ToClientTemplate()
    )
</script>
 
<script>
    function onError(e, id) {
        console.log(id);
    }
</script>


Regards,
Alexander Popov
Telerik
 

Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

 
0
Spirent
Top achievements
Rank 1
answered on 04 Nov 2014, 08:47 PM
Thanks that worked great.
Tags
Grid
Asked by
Spirent
Top achievements
Rank 1
Answers by
Alexander Popov
Telerik team
Spirent
Top achievements
Rank 1
Share this question
or