Convert column in Kendo Grid from int to string

2 posts, 0 answers
  1. Richard
    Richard avatar
    9 posts
    Member since:
    Jun 2016

    Posted 10 Jul Link to this post

    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()

  2. Viktor Tachev
    Admin
    Viktor Tachev avatar
    1727 posts

    Posted 12 Jul Link to this post

    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.
Back to Top