4

I am working with on a task to migrate a dataset from a Telerik RadGrid to a Kendo Grid trying to set up sorting. I got the sorting working fine for most all the columns, however some of the columns have 'ambiguous' (same named) data-field names. The RadGrid accounts for this by allowing me to establish a 'UniqueName' to specify which column.

Kendo Grid Example

    var assignmentColumns = 
    [
        { title: "Last Note Date", field: "NoteDateTime", template: '#= kendo.toString( toDate(NoteDateTime), "M/dd/yyyy h:mmtt" ) #' }
    ];



        var gridDataSource = new kendo.data.DataSource({
            transport: {
                read: {
                    url: '-',
                    type: 'POST',
                    contentType: 'application/json'
                },
                parameterMap: function (options) {
                    return JSON.stringify(options);
                }
            },
            schema: {
                data: 'data',
                total: 'totalItems'
            },
            serverPaging: true,
            pageSize: 10,
            serverFiltering: true,
            serverSorting: true
        });


        $grid.kendoGrid({

            dataSource: gridDataSource,
            pageable: true,
            scrollable: false,
            sortable: {
                allowUnsort: true
            },
            columns: assignmentColumns
        });

Telerik Working Example

<telerik:RadGrid ID="radGrid_Commentary" AllowSorting="true">
    <MasterTableView>
        <Columns>  
            <telerik:GridBoundColumn DataField="NoteDateTime" UniqueName="cg.Date" HeaderText="Date" DataFormatString="{0:MM/dd/yyyy}" />
        </Columns>
    </MasterTableView>
</telerik:RadGrid>

Does anyone have any ideas on how to specify a 'UniqueName' for the kendogrid column?

CatDadCode
  • 58,507
  • 61
  • 212
  • 318
Easton James Harvey
  • 1,672
  • 1
  • 14
  • 24

1 Answers1

3

Okay, after a couple more hours of thinking and fiddling i figured it out. The template handles what gets displayed on screen, the field is what the sort/filter uses when it passes information back for server-side sorting/filtering. I probably should have figured this out sooner, but I hope this can help someone else who is experiencing a similar brainfart.

Modification from above:

var assignmentColumns = 
[
    { title: "Last Note Date", field: "cg.Date", template: '#= kendo.toString( toDate(NoteDateTime), "M/dd/yyyy h:mmtt" ) #' }
];
Easton James Harvey
  • 1,672
  • 1
  • 14
  • 24