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

3 posts, 0 answers
  1. Spirent
    Spirent avatar
    13 posts
    Member since:
    Apr 2012

    Posted 30 Oct 2014 Link to this post

    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. Alexander Popov
    Admin
    Alexander Popov avatar
    1444 posts

    Posted 03 Nov 2014 Link to this post

    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.

     
  3. Spirent
    Spirent avatar
    13 posts
    Member since:
    Apr 2012

    Posted 04 Nov 2014 in reply to Alexander Popov Link to this post

    Thanks that worked great.
Back to Top