0

I want to implement a grid where there are some default values and the user can add more. So, on the default rows it should only have an edit button, but on the others it should appear a edit and a delete button. How can I have different buttons for different rows.

This is my .cshtml with the grid, at the moment with an edit and delete button on every row

@(Html.Kendo().Grid<GenericGridDTO>()
              .Name(gridName)
              .Columns(columns =>
              {
                  switch (Model.ControlType)
                  {
                      case ControlTypeEnum.OneRow:
                          columns.Bound(m => m.Specification);
                          break;
                      case ControlTypeEnum.TwoRow:
                          columns.Bound(m => m.Parameter);
                          columns.Bound(m => m.Specification);
                          break;
                  }
                  columns.Command(command => { command.Edit(); command.Destroy(); }).Width(AppConstants.gridActionsWidth);
              })
              .ToolBar(toolbar => toolbar.Create())
              .Editable(editable => editable.Mode(GridEditMode.InLine))
              .DataSource(dataSource => dataSource
                .Ajax()
                .Sort(sort => sort.Add("Order").Ascending())
                .Model(model =>
                {
                    model.Id(p => p.Id);
                    model.Field(f => f.ParentId).DefaultValue(Model.ParentId);
                    model.Field(f => f.TableId).DefaultValue(Model.TableId);
                    model.Field(f => f.Order).DefaultValue(Model.DataSource.OrderBy(d => d.Order).LastOrDefault().Order + 1);
                    model.Field(f => f.ParentTable).DefaultValue(Model.ParentTable);
                })
                .Create(update => update.Action("CreateGeneric", "Generic"))
                .Update(update => update.Action("EditGeneric", "Generic"))
                .Destroy(update => update.Action("DeleteGeneric", "Generic"))
              )
              .BindTo(Model.DataSource)
              )

At GenericGridDTO.cs I have this

//Id of default parameter, null if manually added
public int? DefaultParameterId { get; set; }
  • This should help you : http://stackoverflow.com/a/20881973/2196341 – Polynomial Proton Apr 10 '15 at 18:50
  • You just need a javascript function to run when someone clicks the row, then you can check your project specific criteria in the function and add a button to edit or allor edit etc – Polynomial Proton Apr 10 '15 at 18:51
  • Thanks for your help, I achieved what I wanted with something similar to what you have shown me. Now I'm trying to use the same condition to determine if a parameter should be editable or not. [link](http://www.telerik.com/forums/how-do-i-conditional-set-the-visibility-of-the-command-edit-button-on-a-row-by-row-basis-) – Pedro Emanuel Sousa Apr 13 '15 at 11:01

0 Answers0