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

Convert column in Kendo Grid from int to string

1 Answer 525 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Richard
Top achievements
Rank 1
Richard asked on 10 Jul 2017, 04:02 PM

This is probably an easy answer but even after searching through documentation i haven't figured it out yet. I have a column in a Kendo Grid that i would like to convert from an integer to a string for filtering purposes. Basically on my ID column, if the user types in 3 it will filter the records for 3, 13, 23 33, ect. Right now what it does in the filter after i type in 3 and hit enter, it converts it to 33.00 Below is the Column

 

columns.Bound(c => c.ID).Title("Ticket No.")

.ClientTemplate(@Html.ActionLink("#=ID#", "View", new { ID = "#=ID#" }).ToHtmlString())

.Filterable(ftb => ftb.Cell(cell => cell.Operator("contains")));

// Something here like .ToString()

1 Answer, 1 is accepted

Sort by
0
Viktor Tachev
Telerik team
answered on 12 Jul 2017, 09:27 AM
Hello Richard,

In order to make the Grid treat a numeric field as a string you can use the Model configuration in DataSource. The DataSource would look similar to the following. 


.DataSource(dataSource => dataSource
    .Ajax()
    .Model(model =>
    {
        model.Id(p => p.ProductID);
        model.Field(p => p.ProductID).Editable(false);
        model.Field("UnitPrice", typeof(string));
 
    })
    .PageSize(20)
    .Read(read => read.Action("EditingCustom_Read", "Grid"))
)


Regards,
Viktor Tachev
Progress Telerik
Try our brand new, jQuery-free Angular 2 components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
Tags
Grid
Asked by
Richard
Top achievements
Rank 1
Answers by
Viktor Tachev
Telerik team
Share this question
or