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

Error event handle in Datagrid

4 Answers 140 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Blair
Top achievements
Rank 1
Blair asked on 11 Jun 2013, 11:40 PM
Hi,

I am using Datagrid and would like to add the error handle function. Follow the doc from Kendo and I change the code as below in sample project. But the error always fired no matter with error or not. Can support team help? Many thanks, George

@(Html.Kendo().Grid<Kendo.Mvc.Examples.Models.OrderViewModel>()    
    .Name("grid")
    .Columns(columns => {
        columns.Bound(p => p.OrderID).Filterable(false).Width(100);
        columns.Bound(p => p.Freight).Width(100);
        columns.Bound(p => p.OrderDate).Format("{0:MM/dd/yyyy}").Width(140);
        columns.Bound(p => p.ShipName);
        columns.Bound(p => p.ShipCity).Width(150);
    })
    .Pageable()
    .Sortable()
    .Scrollable()
    .Filterable()
    .HtmlAttributes(new { style = "height:430px;" })
    .DataSource(dataSource => dataSource
        .Ajax()
        .PageSize(20)
        .Read(read => read.Action("Orders_Read", "Grid"))
        .Events(events => events.Error("alert('errorAlert')"))
     )
)



public ActionResult Orders_Read([DataSourceRequest]DataSourceRequest request)
        {
            return Json(GetOrders().ToDataSourceResult(request));
        }

4 Answers, 1 is accepted

Sort by
0
Daniel
Telerik team
answered on 13 Jun 2013, 11:42 AM
Hello William,

You should pass a reference to a function:

.Events(events => events.Error("function(){alert('errorAlert');}"))
or a function name:
.Events(events => events.Error("alertErrors"))
function alertErrors(){
    alert('errorAlert');
}
instead of executing a function. Regards,
Daniel
Telerik
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
0
Blair
Top achievements
Rank 1
answered on 13 Jun 2013, 10:15 PM
Hi Daniel,
Thanks and it works now.
0
Blair
Top achievements
Rank 1
answered on 17 Jun 2013, 07:19 AM
Hi Denial,
I am working on my project which need Kendo DataViz including Gauge, Datagrid, PieChart and Bar Chart. I have tested Datagrid error event handler according your sample code, thanks for that.  But Gauge doesn't work. Would you please advice me if I should use global error handler or handle it individually? Also can you please provide some sample code for gauge error handler?

Many thanks,
George

 function RefreshChart4() {
         $("#PeriodInt").val( parseInt($("#PeriodInt").val())+1);
         $.get("../DashboardBrowser/GetData_SMDRReceiverMonitorChart?PeriodInt="+$("#PeriodInt").val(),
            function (data) {
                $("#SMDRReceiverMonitorChart").data("kendoRadialGauge").value(data["Percentage"]);
                $("#SMDRName").text(data["Name"] + '');
                $("#Processed").val(data["ReceiverProcessed"]);
                $("#TotalNumber").val(data["ReceiverTotal"]);
            }).fail(function() { //alert("Service Exception"); 
            }); 
    }



 @(Html.Kendo().RadialGauge()
        .Name("SMDRReceiverMonitorChart")
        .Theme("Not Parsed Number")
                .Pointer(pointer => pointer.Value(0).Color("#808080"))
        .Scale(scale => scale
            .MinorUnit(5)
            .StartAngle(-60)
            .EndAngle(240)
            .Max(100)
            .Labels(labels => labels
                .Position(GaugeRadialScaleLabelsPosition.Inside)
                .Font("8px 'Lato','Segoe UI Light',Helvetica,sans-serif")
            )
            .Ranges(ranges =>
            {
                ranges.Add().From(0).To(20).Color("red");
                ranges.Add().From(20).To(40).Color("#FF8517");
                ranges.Add().From(40).To(60).Color("#FCD209");
                ranges.Add().From(60).To(80).Color("#8ebc00");
                ranges.Add().From(80).To(100).Color("#309B46");
            })
        )
    )

0
Daniel
Telerik team
answered on 18 Jun 2013, 02:11 PM
Hi William,

The Gauge does not have an error handler because it does not load any data. What problems are you experiencing with the widget? The code that you provided looks correct.

Regards,
Daniel
Telerik
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
Tags
Grid
Asked by
Blair
Top achievements
Rank 1
Answers by
Daniel
Telerik team
Blair
Top achievements
Rank 1
Share this question
or