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

Custom validation on telerik mvc inline grid save event

1 Answer 705 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Veena
Top achievements
Rank 1
Veena asked on 31 Dec 2015, 09:27 PM

I have a inline grid and 'sumBudgetAmount' value in a page. When user clicks edit and updates 'IncreaseByAmt' in the grid, I have to check the sum of all the records of 'IncreaseByAmt' in the grid and see it is not greater than 'sumBudgetAmount' value. I want to do client side validation on gridsave event.

I can not do server side validation as I am not updating to the database when user clicks update button. It is a batch editing where user clicks save and then I am saving all the values to the database. So I can use only client side validation.

 

<span id="sumBudgetAmt"> @(Model.SumBudgetAmount) </span>
 
@(Html.Kendo().Grid<BHEBS.Areas.Budget.Models.ContractBudgetModel.ServiceDetailReallocation>()
            .Name("serviceDetailReallocationGrid")
            .Columns(columns =>
            {
                columns.Bound(p => p.ServiceDetailId).Hidden(true);             
                columns.Bound(p => p.IncreaseByAmt).EditorTemplateName("Currency").Format("{0:c}");
                columns.Command(command =>
                {
                    command.Edit().HtmlAttributes(new { @class = "btn-primary" });
                }).Width(230);
            })
            .Events(e => e.Save("onServiceDetailReallocationGridSave"))                
            .DataSource(dataSource => dataSource.Ajax().ServerOperation(false).Read(read => read.Action("ServiceDetailReallocation_Read", "ContractBudget"))
            .Model(model =>
            {
                model.Id(p => p.ServiceDetailId);
            })
            .Update(update => update.Action("Update_ServiceDetailReallocation", "ContractBudget"))
            .Events(e => e.Error(@<text> function(args) {var gridName = 'serviceDetailReallocationGrid';errorGrid(args, gridName);  }  </text>))
            ))

 

 

Thanks,

Veena

1 Answer, 1 is accepted

Sort by
0
Boyan Dimitrov
Telerik team
answered on 04 Jan 2016, 04:15 PM

Hello Veena,

 

My suggestion is to review the Grid / Custom validator editing demo that shows how to implement such behavior. 

 

Please let us know if you need any further assistance. 

 

Regards,
Boyan Dimitrov
Telerik
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
Tags
Grid
Asked by
Veena
Top achievements
Rank 1
Answers by
Boyan Dimitrov
Telerik team
Share this question
or