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

reference grid generated by template AND/OR programmatically enable/disable column editing

1 Answer 74 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Shannon
Top achievements
Rank 1
Shannon asked on 04 Dec 2012, 05:33 PM
I have a grid that is generated by a template.  How do I reference that grid from my javascript? I am trying to do this to enable editing of a column value on Create but not on Edit.  If there is an easier/better way to do that, I would appreciate your help. Either way, I'd still like to know how to reference the other grid.

My template name and grid name are setup as follows:
<script id="npisTemplate" type="text/kendo-tmpl">
<%: Html.Kendo().Grid<MyModel>()
.Name("Abc_#=PersonId#")
//.............
</script>
And I have tried various ways of referencing it but all generate an error:
<script>
      $("#Npi_#=FacilityAbbreviation#").kendoGrid()...  // error
      $("Npi_#=FacilityAbbreviation#").kendoGrid()...  // error
</script>

Thanks in advance for your help

1 Answer, 1 is accepted

Sort by
0
Petur Subev
Telerik team
answered on 06 Dec 2012, 11:18 AM
Hello Shannon,

I assume that you create hierarchy of Grids. If this is the case please notice that it is not one Grid - there are multiple Grids.
And with the client expression #= # each of the Grids receives unique name. e.g.
$("#Npi_1").data('kendoGrid')...
$("#Npi_2").data('kendoGrid')...  // 1,2 is on the place of the FacilityAbbreviation or whatever values this property may have

I hope this makes clearer what is actually the name of the generated child Grids.

Kind Regards,
Petur Subev
the Telerik team
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
Tags
Grid
Asked by
Shannon
Top achievements
Rank 1
Answers by
Petur Subev
Telerik team
Share this question
or