Is leverage the "change" event the correct approach to wire up some templates and grid that use a common DataSource?
I have the following code, but it take about 5 seconds for the binding to occur even though the data is returned in under a second.
<script>
$(document).ready(function () {
var dsBoxScore = new kendo.data.DataSource(
{
type: "json",
transport:
{
read: "JsonBoxScoreGet"
},
change: function () {
var scriptTemplateBoxscoreHomeTeam = kendo.template($("#templateBoxScoreHomeTeam").html());
$("#scriptBoxScoreHomeTeam").html(scriptTemplateBoxscoreHomeTeam(this.data().HomeTeam));
var scriptTemplateBoxscoreAwayTeam = kendo.template($("#templateBoxScoreAwayTeam").html());
$("#scriptBoxScoreAwayTeam").html(scriptTemplateBoxscoreAwayTeam(this.data().AwayTeam));
$("#gridBoxScore").kendoGrid({
dataSource: this.data().HomeTeam.Players,
height: 350,
selectable: "row",
scrollable: true,
sortable: true,
pageable: false,
navigatable: true,
rowTemplate: kendo.template($("#rowTemplateBoxScorePlayerStats").html())
});
},
serverPaging: false,
serverSorting: false
});
dsBoxScore.read();
});
</script>
I have the following code, but it take about 5 seconds for the binding to occur even though the data is returned in under a second.
<script>
$(document).ready(function () {
var dsBoxScore = new kendo.data.DataSource(
{
type: "json",
transport:
{
read: "JsonBoxScoreGet"
},
change: function () {
var scriptTemplateBoxscoreHomeTeam = kendo.template($("#templateBoxScoreHomeTeam").html());
$("#scriptBoxScoreHomeTeam").html(scriptTemplateBoxscoreHomeTeam(this.data().HomeTeam));
var scriptTemplateBoxscoreAwayTeam = kendo.template($("#templateBoxScoreAwayTeam").html());
$("#scriptBoxScoreAwayTeam").html(scriptTemplateBoxscoreAwayTeam(this.data().AwayTeam));
$("#gridBoxScore").kendoGrid({
dataSource: this.data().HomeTeam.Players,
height: 350,
selectable: "row",
scrollable: true,
sortable: true,
pageable: false,
navigatable: true,
rowTemplate: kendo.template($("#rowTemplateBoxScorePlayerStats").html())
});
},
serverPaging: false,
serverSorting: false
});
dsBoxScore.read();
});
</script>