2014-02-14 50 views
0

我正在使用以下的Kendo網格。在KendoUI網格中避免重複的coumn條目

@(Html.Kendo().Grid<EStoreApp.Models.Entity.AccountGroup>() 
    .Name("grid") 
    .Columns(columns => 
    { 
     columns.Bound(p => p.AccountGroupCode).Width(140).Title("Account Group Code"); 
     columns.Bound(p => p.AccountGroupName).Width(140).Title("Account Group Name"); 
     columns.Bound(p => p.ParentGroupName).Width(140).Title("Parent Group Name"); 
     columns.Bound(p => p.Remarks).Width(140).Title("Remarks"); 

     columns.Command(command => { command.Edit(); command.Destroy(); }).Width(170); 
    }) 
     .ToolBar(toolbar => toolbar.Create().Text("Add New Account Group")) 
      .Editable(editable => editable.Mode(GridEditMode.PopUp).TemplateName("AccountGroupEditor").Window(w => w.Title("Account Group") 
    .Width(500))) 

    .Pageable() 
    .Filterable() 
    .Sortable() 
    .Scrollable() 
    .HtmlAttributes(new { style = "height:430px;" })  

    .DataSource(dataSource => dataSource 
      .Ajax().Read(read => read.Action("GetAllAccountGroups", "AccountGroup").Data("getAdditionalData")) 
    .PageSize(20) 
    //.Events(events => events.Error("error_handler")) 
    .Model(model => model.Id(p => p.AccountGroupId)) 
     .Create(update => update.Action("Create", "AccountGroup")) 
     .Update(update => update.Action("Update", "AccountGroup")) 
     .Destroy(update => update.Action("Destroy", "AccountGroup")) 
    ) 
    ) 

我想在添加新賬戶時檢查「賬戶組碼」是否已經存在。我如何使用Kendo網格來做到這一點?

回答

0

您應該修改您的服務器端代碼,以確保您只在數據中獲得唯一的帳戶組代碼,而不是試圖使您的網格過濾出類似的數據。

更改您的GetAllAccountGroups操作以執行數據檢索過濾。

read.Action("GetAllAccountGroups", "AccountGroup").Data("getAdditionalData")