Tuesday, 15 March 2011

asp.net mvc - Kendo Grid Conditional Destroy and Show Message -



asp.net mvc - Kendo Grid Conditional Destroy and Show Message -

i have kendo grid, when user clicks delete button controller must create operations. according operations, info not deleted should show message 'you can not delete record' how this?

@(html.kendo().grid<teknik.models.magaza_viewmodel>() .name("grid") .columns(columns => { columns.bound(p => p.id).visible(false); columns.bound(p => p.name); columns.command(command => { command.edit(); command.destroy(); }); }) .editable(editable => editable.mode(grideditmode.popup).templatename("tmpmagaza").createat(gridinsertrowposition.top)) .datasource(datasource => datasource .ajax() .pagesize(20) .model(model => model.id(p => p.id) ) .create(update => update.action("create", "home")) .read(read => read.action("read", "home")) .update(update => update.action("update", "home")) .destroy(update => update.action("destroy", "home")) )

)

controller destroy action:

[acceptverbs(httpverbs.post)] public actionresult destroy([datasourcerequest] datasourcerequest request, magaza_viewmodel magaza) { if (magaza != null) { if (!valid) { // record not deleted, show message } else { magazamodel.destroy(magaza); } } homecoming json(new[] { magaza }.todatasourceresult(request, modelstate)); }

a improve method hide commands user not have access to. create column, utilize client template determine said within column. client template allows utilize javascript placing within '#' characters, can include conditional statements. html phone call same action destroy command have called.

columns.bound(p => p.id).visible(false); columns.bound(p => p.name); columns.command(command =>command.edit()); columns.bound(p =>p.id).clienttemplate("#if(condition){#html1#}#");

asp.net-mvc razor kendo-grid kendo-asp.net-mvc

No comments:

Post a Comment