Create unique name for grid in template

2 posts, 0 answers
  1. Ludek Soukup
    Ludek Soukup avatar
    3 posts
    Member since:
    Apr 2009

    Posted 18 Aug Link to this post

    I need to create unique grid name inside template, i try with javascript, but it doesn't work.

    <script id="conditionGroupTemplate" type="text/x-kendo-template">
                      .Name("entryGroupConditions" + //here i need to call getGUID()//)
                      .Columns(columns =>
                          columns.Bound(o => o.Text);
                          columns.Command(command =>
                      .ToolBar(toolbar =>
                          toolbar.Template("<div class='toolbar'><a class='k-button k-button-icontext pull-left' onClick='AddGroup(\"\\#entryGroupConditions\", \"Skupina podmínek\")'><span class='k-icon k-add'></span>Přidat skupinu</a><h3>AND</h3></div>");
                      .DataSource(ds => ds
                          .Model(m => m.Id(o => o.Path))
                          .Destroy(del => del.Action("DeleteAttribute", "Rule"))
                      .Resizable(resize => resize.Columns(true))

    function getGUID(){       
            return (salt() + salt() + "-" + salt() + "-4" + salt().substr(0,3) + "-" + salt() + "-" + salt() + salt() + salt()).toLowerCase();
        function salt(){
            return (((1+Math.random())*0x10000)|0).toString(16).substring(1);

    Any help?

  2. Dimo
    Dimo avatar
    8322 posts

    Posted 22 Aug Link to this post

    Hi Ludek,

    The Name string of the Grid can contain a Kendo UI template expression, for example:


    ... where EmployeeID is the unique primary key field in the master Grid.

    One may expect to be able to use something like this:


    However, this approach cannot be used for widget names, due to special escaping that occurs behind the scenes.

    That's why the expression inside the Grid Name() can only contain a variable reference, and no function calls or arithmetic operators. The variable can be either a custom global variable from the page, or a field from the master Grid's data item.

    Telerik by Progress
    Get started with Kendo UI in days. Online training courses help you quickly implement components into your apps.
Back to Top