Hello,
I have a Telerik ListView inside a partial view that is rendered inside a kendo Window in modal mode. Using MVC5.
The listview is setup to query the controller for records (which are image files).
In the edit view for my model, and the user can select an image to be part of the model's data. I want them to select from maybe 5000 images on our system. So the Listview popup starts with 6 visible images (pagesize is 6) and they can cycle via paging to the image they want to select.
This all works fine.
Currently when the listbox is displayed, (after a button click on view), it always shows the very first 6. Consider case where user is editing record 10, and that record has already specified it uses pictureId 50 (pictureID is foreign key to picture table). I want the listbox to show Item 50 in its selected page, but allow the user to page back to other pages, or page forward. The page backs/forwards will do the datarequests as needed.
I added a "save" button to the popup window so i could test out code. My listview is named "imageListView".
In my sample, i just wanted to choose item 9, as an example.
If i first navigate to page 2 so item 9 is shown on the listview, then the below code works fine.
but if i am on page 1 (items 1-6 shown), the get(9) call returns null.
how can i figure out what page to go to prior to actually loading the items on the page?
I have a Telerik ListView inside a partial view that is rendered inside a kendo Window in modal mode. Using MVC5.
The listview is setup to query the controller for records (which are image files).
In the edit view for my model, and the user can select an image to be part of the model's data. I want them to select from maybe 5000 images on our system. So the Listview popup starts with 6 visible images (pagesize is 6) and they can cycle via paging to the image they want to select.
This all works fine.
Currently when the listbox is displayed, (after a button click on view), it always shows the very first 6. Consider case where user is editing record 10, and that record has already specified it uses pictureId 50 (pictureID is foreign key to picture table). I want the listbox to show Item 50 in its selected page, but allow the user to page back to other pages, or page forward. The page backs/forwards will do the datarequests as needed.
I added a "save" button to the popup window so i could test out code. My listview is named "imageListView".
In my sample, i just wanted to choose item 9, as an example.
If i first navigate to page 2 so item 9 is shown on the listview, then the below code works fine.
but if i am on page 1 (items 1-6 shown), the get(9) call returns null.
how can i figure out what page to go to prior to actually loading the items on the page?
$("#save").click(function () {
var lv = $("#imageListView").data("kendoListView");
var model = lv.dataSource.get(9);
var index = lv.dataSource.indexOf(model);
var pg = Math.floor(index / lv.dataSource.pageSize()) + 1;
lv.dataSource.page(pg);
}