I am having some issues with a listView. I am populating it with information, I have each listView Item clickable to another screen to edit the item. But sometimes when I navigate back, the listView shows no data at all. When I debug my code I can see that data is being returned every single time and the listView is being re-bound. The data is also displayed in the HTML markup of my page, so I know it returned it.
Here is a copy of the code I am using along with some screen shots.
WidgetListView.prototype.initView = function (initEvent) {
var thisClass = this;
//Grab data
thisClass.listView = new kendo.data.DataSource({
transport: {
read: $.ajax({
type: "POST",
url: thisClass.loadEndpoint,
contentType: 'application/json; charset=utf-8',
dataType: "json",
headers: { 'x-sauthcode': localStorage["authCode"] },
data: JSON.stringify(
thisClass.loadEndpointData()
),
success: function (result, status) {
thisClass.viewModel.set("data", result); //this part here always has data even if the listView does not display it
if (result.length > 0) {
//prepare Data if needed
thisClass.prepareDataEvent(result);
///bind the listView to element ID
$(thisClass.listViewId).kendoMobileListView({
dataSource: thisClass.viewModel.get("data"),
//bind template ID
template: $(thisClass.templateId).text(),
click: function (e) {
thisClass.clickEvent(e);
}
});
//Do post data checks
thisClass.postGetEvent(result);
} else {
//console.log(noResultsMsg);
thisClass.noResultsEvent(thisClass.noResultsMsg);
}
},
error: function (error) {
console.log(error);
//Handle Errors
thisClass.errorEvent();
}
})
}
});
};
Here is my HTML code:
<div data-role="content">
<ul id="historyList" data-role="listview" data-style="inset" data-template="historyTemplate"></ul>
</div>
My Template:
<script type="script/x-kendo-template" id="historyTemplate">
<div class="listViewItem">
<div id="ListItemRow">
<div id="ListItemLabel">Status:</div>
<div id="ListItemValue">#: (Status != null) ? Status : '' # </div>
</div>
<div id="ListItemRow">
<div id="ListItemLabel">Date:</div>
<div id="ListItemValue">#: (StatusDate != null) ? dateFormat(StatusDate, "m/d/yyyy", true) : '' # </div>
</div>
<div id="ListItemRow">
<div id="ListItemLabel">Modified:</div>
<div id="ListItemValue">#: (ModifiedBy != null) ? ModifiedBy : '' # </div>
</div>
</div>
</script>
any help to why the list binds most of the time but sometimes randomly does not, even though data was returned the HTML would be great. Thanks for the help!
Here is a copy of the code I am using along with some screen shots.
WidgetListView.prototype.initView = function (initEvent) {
var thisClass = this;
//Grab data
thisClass.listView = new kendo.data.DataSource({
transport: {
read: $.ajax({
type: "POST",
url: thisClass.loadEndpoint,
contentType: 'application/json; charset=utf-8',
dataType: "json",
headers: { 'x-sauthcode': localStorage["authCode"] },
data: JSON.stringify(
thisClass.loadEndpointData()
),
success: function (result, status) {
thisClass.viewModel.set("data", result); //this part here always has data even if the listView does not display it
if (result.length > 0) {
//prepare Data if needed
thisClass.prepareDataEvent(result);
///bind the listView to element ID
$(thisClass.listViewId).kendoMobileListView({
dataSource: thisClass.viewModel.get("data"),
//bind template ID
template: $(thisClass.templateId).text(),
click: function (e) {
thisClass.clickEvent(e);
}
});
//Do post data checks
thisClass.postGetEvent(result);
} else {
//console.log(noResultsMsg);
thisClass.noResultsEvent(thisClass.noResultsMsg);
}
},
error: function (error) {
console.log(error);
//Handle Errors
thisClass.errorEvent();
}
})
}
});
};
Here is my HTML code:
<div data-role="content">
<ul id="historyList" data-role="listview" data-style="inset" data-template="historyTemplate"></ul>
</div>
My Template:
<script type="script/x-kendo-template" id="historyTemplate">
<div class="listViewItem">
<div id="ListItemRow">
<div id="ListItemLabel">Status:</div>
<div id="ListItemValue">#: (Status != null) ? Status : '' # </div>
</div>
<div id="ListItemRow">
<div id="ListItemLabel">Date:</div>
<div id="ListItemValue">#: (StatusDate != null) ? dateFormat(StatusDate, "m/d/yyyy", true) : '' # </div>
</div>
<div id="ListItemRow">
<div id="ListItemLabel">Modified:</div>
<div id="ListItemValue">#: (ModifiedBy != null) ? ModifiedBy : '' # </div>
</div>
</div>
</script>
any help to why the list binds most of the time but sometimes randomly does not, even though data was returned the HTML would be great. Thanks for the help!