How do I set a “UniqueName” on a Kendo Grid like you can with a Telerik RadGrid?

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?

Answers:

Answer

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" ) #' }
];

Tags

Recent Questions

Top Questions

Home Tags Terms of Service Privacy Policy DMCA Contact Us

©2020 All rights reserved.