I have series of data in one page in which I am getting data of past two days using linq. I want to create a button clicking which gets 5 more days data. Please find the code for getting 2 days data. I need to add this to my code press to load more
https://demos.telerik.com/kendo-ui/m/index#mobile-listview/press-to-load-more
<div data-role="view" id="divData">
<ul data-role="listview" data-bind="ListofEmployeeData">
<li>
<span data-bind="text:EmpID"></span>
<span data-bind="text:EmpName"></span>
<span data-bind="text:Empemail"></span>
</li>
</ul>
</div>
function EmployeeDetails() {
self.ListofEmployeeData = ko.observableArray([]);
self.getTotalStarRating = function () {
///Mobile DeviceUUId
var Model = {deviceUUID: deviceId};
$.ajax({
type: "POST",
dataType: "json",
data: Model,
url: serverUrl + 'xx/xx/xx',
success: function (data) {
self.ListofEmployeeData($.map(data, function (item) {
return new EmployeeModel(item);
}));
}
});
}
}
function EmployeeModel(item)
{
self.EmpID=ko.observable(item.empId);
self.EmpName=ko.observable(item.EmpName);
self.Empemail=ko.observable(item.Empemail);
}
You need to have a property in your data request to the server that indicate which day you want to load or how many days and in your server side you only return data based on that property I call it here
DayNumber
.If you need to press Load more only one time and not any more you can hide your button in your ajax success. But if you want to keep loading data and you have no idea how much more data left you need to change the logic somehow in your back-end that send with return data.
The next thing, you need to push new element to your array every time you get data.
Don't forget to keep
this
separate in each model and sub model. Also in your view I see you bind<ul data-role="listview" data-bind="ListofEmployeeData">
but you forgot to put binding name likeforeach :ListofEmployeeData