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

Dynamic Grids with Dynamic DataSource

1 Answer 165 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Joshua
Top achievements
Rank 1
Joshua asked on 13 Mar 2012, 08:39 PM
I want to place a grid inside of a template. I also want it to be able to use URLs to bind to. Is there a best way to do that?

Right now, I am using the template to out put the datasource through stringify and then reparsing it.

I have an object that has a person and a rockoverview.rocks members. since these grids are dynamic and can have multiples on the same page, i need to create a unique id and refer to it uniquely.

$("\#grdStuck#=data.Person.ID#").kendoGrid(
{
   dataSource: JSON.parse('#=kendo.stringify(data.RockOverview.Rocks)#'),
   sortable: false,
   pageable: false,
   scrollable: false
});

I have created an extremely simple example that demonstrates what i am trying to accomplish.
http://jsfiddle.net/aPXsg/5/

1 Answer, 1 is accepted

Sort by
0
Joshua
Top achievements
Rank 1
answered on 13 Mar 2012, 10:55 PM
ok, I figured it out.

since the template is not going to be evaluated until later, i have to escape the fieldname so that the template engine does not try to evaluate immediately.

   <script id="DetailsTemplate" type="text/x-kendo-template">        
        <div id="grd"></div>
        <script type="text/javascript">           
            var tmpData = jQuery.parseJSON('#= kendo.stringify(data) #');
                        
            $("\#grd").kendoGrid
            ({
                dataSource: tmpData.ValArray,
                columns: [
                    { "title": "My ID", "field": "ID" },
                    { "title": "My Value", "field": "Value" }
                    ,{ "title": "Alert", "template": "This has a value field = \#=Value\#" }
                ]
            });
        </script>
    </script> 
Tags
Grid
Asked by
Joshua
Top achievements
Rank 1
Answers by
Joshua
Top achievements
Rank 1
Share this question
or