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

Can grid handle manually injecting HTML?

4 Answers 83 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Next
Top achievements
Rank 1
Next asked on 16 Dec 2011, 07:04 PM
I have the grid system correctly pulling the information from JSON, however I need to know if there is a way to add certain HTML elements to show up on the grid.
For example the grid shows all the columns of information about a music artist, but the last column I want to add a form with a submit button or a html link saying "Add to favorites" or "View artist".

All of the grid populating seems to be done in the backend of the js files and I dont know if there is an easier way or not.

Thank you

4 Answers, 1 is accepted

Sort by
0
Accepted
Brandon
Top achievements
Rank 1
answered on 16 Dec 2011, 07:47 PM

Did you try setting a template for the column?

When you intialize your grid, try something like:

$("#gridEmailAddress").kendoGrid({
dataSource: mydatasource,
columns: [
{ field: "Address", width: 190, title: "Email Address" },
{ field: "Name", width: 190, title: "Name" },
{ template: "blah" },
{ command: "destroy", title: " ", width: 120 }
]
});

Instead of "blah", insert your own html code. 

0
Next
Top achievements
Rank 1
answered on 16 Dec 2011, 08:27 PM
I played with the template part before but using the way you put the code it actually works now. Thank you.

However, can the template handle the information coming from JSON? For example
{   field: "id",
    title: "Actions",
    template: "<a href='edit.php?id=" + id + "'>Edit</a> | <a href='delete'>Delete</a>" },

How can I get the "id" from the JSON information to be in the html?
0
Brandon
Top achievements
Rank 1
answered on 16 Dec 2011, 08:56 PM
Use the pound sign operater.

http://demos.kendoui.com/web/templates/expressions.html
{   field: "id",
  
    title: "Actions",
  
    template: "<a href='edit.php?id=#=Id#'>Edit</a> | <a href='delete'>Delete</a>" },
0
Next
Top achievements
Rank 1
answered on 16 Dec 2011, 09:06 PM
Genius. Thank you good sir.
Tags
Grid
Asked by
Next
Top achievements
Rank 1
Answers by
Brandon
Top achievements
Rank 1
Next
Top achievements
Rank 1
Share this question
or