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

Add a command column in a dynamic grid

2 Answers 269 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Frederic
Top achievements
Rank 1
Frederic asked on 03 Jul 2013, 08:36 AM
Hello,

I have a grid that is dynamically filled with data that I do not know the name and I want to add a command column to this grid but it seems that I need to define the colums before this command column like this :

$("#grid").kendoGrid({
  columns: [
    { field: "name" },
    { command: [{ className: "btn-destroy", name: "destroy", text: "Remove" }] }
  ],
  editable: true,
  dataSource: [ { name: "Jane Doe" } ]
});
But I can't because as I said I don't know the names of my columns ... How can I do this ?

Thanks.


2 Answers, 1 is accepted

Sort by
0
Vladimir Iliev
Telerik team
answered on 05 Jul 2013, 06:40 AM
Hi Frederic,

 
Including command column will remove the auto-generated columns - that's why the desired behavior will require custom solution. For example you can get one of the dataItems passed to the dataSource and generate the columns based on current properties that are available in the object.

For convenience I created small jsBin example based on the above solution which you can use as a baseline.

Kind Regards,
Vladimir Iliev
Telerik
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
0
Frederic
Top achievements
Rank 1
answered on 05 Jul 2013, 09:17 AM
Hi Vladimir,

Thank you very much, this is exactly what I wanted !
Tags
Grid
Asked by
Frederic
Top achievements
Rank 1
Answers by
Vladimir Iliev
Telerik team
Frederic
Top achievements
Rank 1
Share this question
or