Cell Style in Json Data

4 posts, 0 answers
  1. Matteo Fabris
    Matteo Fabris avatar
    8 posts
    Member since:
    Aug 2012

    Posted 19 Feb Link to this post

    Hello.

    I'm developing with Kendo Grid and I have a question about styling cell of every row.

    I've already read some articles to style every cell in databound event.

    Can I add styling rule in JSON Data Passed to Kendo Grid?

    In my case I have a datatable(vb.net) that I convert to json before pass to kengo grid.

    My datatable has 3 column and 50 rows.

    1° col: Name / 2° col: Surname / 3° col: Style.

    Every row can have a different "Style" content.  "Style" is the style that I need to apply to 1° and 2° column.

    Example:

    PAUL   BEAN    color:red;    

    STEVE    JOBS    text-align:center;

    SAM    SMITH    background-color: green;

    {"data":[{"Name": "Paul", "Surname":"Bean","Style":"color:red"}, {"Name": "Steve", "Surname":"Jobs","Style":"text-align:center"}, {"Name": "Sam", "Surname":"Smith","Style":"background-color: green;"}]}

     

    Can you explain If is possibile styling on json "data"?

    I've already use databound event and I Iterate every rows but it is very slow.

    Are there any alternatives?

     

    thanks!

     

  2. Georgi
    Admin
    Georgi avatar
    704 posts

    Posted 22 Feb Link to this post

    Hi Matteo,

    One way to achieve that is to define a custom rowTemplate as shown in the following demo:

    Please note that within the row template you have access to all fields of the model.

    Regards,
    Georgi
    Progress Telerik

    Virtual Classroom, the free self-paced technical training that gets you up to speed with Telerik and Kendo UI products quickly just got a fresh new look + new and improved content including a brand new Blazor course! Check it out at https://learn.telerik.com/.

  3. Matteo Fabris
    Matteo Fabris avatar
    8 posts
    Member since:
    Aug 2012

    Posted 01 Mar in reply to Georgi Link to this post

    Hello Georgi,

    thanky you for reply.

    Can you explain me how to define row template at runtime?

    Thanks

  4. Georgi
    Admin
    Georgi avatar
    704 posts

    Posted 02 Mar Link to this post

    Hi Matteo,

    I've created a small sample which demonstrates how to iterate through the fields of the model and create a row template dynamically:

    I hope this helps.

    Regards,
    Georgi
    Progress Telerik

    Virtual Classroom, the free self-paced technical training that gets you up to speed with Telerik and Kendo UI products quickly just got a fresh new look + new and improved content including a brand new Blazor course! Check it out at https://learn.telerik.com/.

Back to Top