How to change kendo grid selected page number without rebinding? - kendo-ui

I have a kendo grid with custom binding, the selected page is informed by the datasource (sent by the server). Everything is working, only part missing is how to set the selected page to the information in the JSON response.
The JSON sent by the server is something like this:
{AggregateResults: null, Data: […], Errors: null, Page: 2, Total: 300}
I did a custom DataSourceResult class, and tried to set the pager and datasource page in the RequestEnd datasource event to the one above, but in both cases, a new call is made to the server.

Related

How to read datasource of a Kendo DropDownList only once?

(MVC Razor) So on my page I have a Kendo grid which contains a DropDownList within a certain column. Now I don't want to fill data of my dropdownlist from controller (With Viewbag/ViewData) before the page loads because it would slow it down, but instead I'd like to fill the DropDownList data on user click with a call to a controller function, and call the read method only once(on first click). How would I be able to achieve this goal?
Set autoBind property to false. It will cause that dropdown will not be filled by data before user click on it.
After component is initialized dataBound event is started so you can set readonly in it.
Demo here

how to avoid calling page_load method when binding grid with different data

i want to change the data in the gridview on a button click by binding it with a different List<> object on server side, It binds the data successfully but since its a post back on button click the grid view gets loaded with the old data which was initialized to it in the page_load method.
how can i avoid calling the page load method after binding the grid with fresh data in the onclick event of my button.
i tried using (!isPostBack) but it dose not help.
Have your button event set a grid parameter that posts back to your server control that indicates that you are changing which datasource feeds the grid, then reload the grid. It should only be now showing the new dataset.
Example:
$('#gridName').jqGrid('setGridParam', { postData: { ChangeGridDataSet: true} }).trigger('reloadGrid', [{ page: 1}]);

Reload jqgrid but also reload the select list which is dynamically loaded through ajax in add/edit modal

in title i have mention what im tryin' to achieve, here is the code i'm working with
i have colModel
....
editoptions:{value:getNames()}
....
function getNames() {
var Names = $.ajax({
url: '/Account/GetNames',
async: false
}).responseText;
return Names;
}
Now when i fire $("#grid").trigger("reloadGrid"); the grid is getting reloaded but the
Action GetNames is not geting called, so the select list on my add/edit modal is not filling up the latest data coming from server..
Im using jquery ui tabs, 2 tabs each tab reders a jqgrid, so let say in 1st tab i add a Name, now on 2nd tab when im adding Contact i show Names in the select list, since both the grid are loaded once, im tryin' to reload the tab on demand, now grid getting reloaded but the script function which's makes ajax request to get Names is not getting hit...
Note: things are working fine for the 1st load when page is loaded, ie my select list is getting populated if i refresh the page after i added Names on my 1st tab..

update dojo datagrid

I need to display a data grid in my website. When user logs into website, an ajax request is send to get whole data for the grid. After that cell updates will come(json response) from dojo ajax requests to server. So how to update those cells only in data grid automatically.
To update items in the datagrid store :
grid.store.fetch({query:{/*find items to update*/},
onItem : function(gridItem){
grid.store.setValue(gridItem, attr, value);
});
grid.store.save();
Setting the attributes you want to update to the appropriate value from the xhr response.

using jqGrid addJSONData function with scroll and loadonce option at same time

in my web application i am already using jqgrid since version 3.5.
at my application such as search window, page is comming with no date. after user entering seach parameter when clicking search buton i have done request, grid data and other variable that i needed has come with this ajax request.
so i populate grid with addJSONData metod such as ;
var data = {"page":"1″,"total":0,"records":0,"rows":[{"id":"1","cell":["1-480","1884","BASYAYLA"]},{"id":"2″,"cell":["2-481","1983","SARIVELILER"]}]};
// data variable has return from ajax request.
var mygrid = jQuery("#mygrid")[0];
mygrid.addJSONData(data);
Grid populating is problem when you working with big data set. Yesterday i seen new properties called scroll and loadonce at demo page.
I understand that when i use datatype except than json.
i try to use these metod but i am not able to success.
How could i use addJSONData, scroll and loadonce at same time.
i find solution myself
when you are using loadonce metod it will turn datatype to local so addJSONData metod dont work because datatype is not json.
by following these steps, problem has solved.
i set datatype local to grid dont make first call
$.extend($.jgrid.defaults,{
datatype: "local"
});
for loading data to grid. i follow these commands;
$("#"+objeId).setGridParam({datatype:'json', loadonce:true});
mygrid.addJSONData(myjsongrid);
$("#"+objeId).setGridParam({datatype:'local'});
every thing work fine for me.

Resources