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

Need advice on how to show and edit nearly completely dynamic data

1 Answer 19 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Dan
Top achievements
Rank 1
Dan asked on 08 Dec 2015, 11:14 PM

I have a database table that is based on this model:

1.public partial class ClientTableRow
2.{
3.    public Guid Id { get; set; }
4.    public Guid TableId { get; set; }
5.    public Guid UserId { get; set; }
6.    public string RowData { get; set; }
7.    public DateTimeOffset CreatedOn { get; set; }
8.}
 

 The RowData contains JSON.

 The API call which retrieves the data, usually by TableId, modifies the JSON somewhat by adding the record's "Id" and "CreatedOn" fields.  The following javascript gives me much of what I want: 

1.$.get('/Data/GetJsonData/' + tableId, function (data) {
2.    var gridName = '#' + tableId + '-grid';
3.    var grid = $(gridName).kendoGrid({
4.        dataSource: data,
5.        selectable: true,
6.        sortable: true
7.    });
8.});

Visually the grid looks good except for the fact that Id show up in the grid... and since it is a Guid consumes a screen space.

There are 3 goals I'd like to achieve.

  1. I would like to make this grid editable.  However, all the examples I've seen on the demo site have fixed, known fields when they are creating the schema in the datasource as well as defining the columns in the grid.
  2. I'd like to hide the Id.  I know I will need it for editing, deleting, and some other tasks mentioned briefly below.
  3. I'd like to add a "Command" column with edit and delete, as well command to pull further related data based on the record Id.

Is there a way to achieve these goals with the fact that we won't know what the Json data looks like?  The only fields that will ever be consistent are the Id and the CreatedOn date since they are attached to the Json before it's sent to the grid. (It *is* safe to assume that all Json data with the same TableId are similar.)

 

 

 

 

1 Answer, 1 is accepted

Sort by
0
Boyan Dimitrov
Telerik team
answered on 10 Dec 2015, 02:40 PM

Hello Dan,

 

Please review this http://dojo.telerik.com/eQoJI example that shows how to create the columns property of the Kendo UI Grid dynamically. Same pattern could be used and create the columns array based on the data returned by the server. Since the configuration of the Kendo UI Grid is a JSON object you can modify other options in the same way. 

 

Regards,
Boyan Dimitrov
Telerik
 
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
 
Tags
Grid
Asked by
Dan
Top achievements
Rank 1
Answers by
Boyan Dimitrov
Telerik team
Share this question
or