Kendo grid function 'selectedKeyNames' not retrieving multiple rows - kendo-ui

I have a Kendo grid with the ability to have multiple rows selected. I'm trying to get all rows selected by using selectedKeyNames method:
var jsonArray = grid.selectedKeyNames();
This doesn't return anything. I went to kendo's example of selectedKeyNames on there site
I removed grid.select("tr:eq(2)");, selected all rows and ran it. After pressing F12, I can inspect the array of rows that should be returned, which is also empty.
How do I use selectedKeyNames to get an array of the rows selected? Or should I be using other functions?

Related

How to handle filterd result during continously refreshing data?

I have no issue to use DataTable, to filter its data and put it into a DefaultView.
The thing is even I use original DataTable or creation of DefaultView to present the filtered data my time dependent operation is getting constantly input that is refreshed in DataTable that is bind to DataGridView and when the filter is active and values are updated row-wise it is refreshed. So it results in this specific visual thing that rows that are filtered out get inserted back but not completely just in 1 column and if I select this row in DataGridView it pushes out an error System.IndexOutoFRangeException.
If no filter is active all is fine.
I need an advise what I need to do to reach my goal:
Even if a filter is active the values should be updated in DataTable (works already) that refreshes DataGridView without a "glitch"glitched so I can select a row without getting the aboves exception.
Solved:
The trick looks simple that solves the glitch too.
myDT = new DataTable();
myDV = new DataView(myDT);
bind the View to DataGridView.

How to save only change data in jqgrid?

I'm using jqgrid.
When the user execute (add/change/delete) rows more than often, and some documents have hundreds of rows.
If a user clicks the Save button, all rows (including no changed rows) are updated at once and it takes a while when rows are in the hundreds.
I just want to update the changed data only.
Is there any row status check function?
To verify whether the data has been changed or not during editing you can use the internal jqGrid option savedRow:
var row = $("#yourGrid").getGridParam("savedRow"); to get the data.
According to the documentation:
The array savedRow (option in the grid) is filled with the values before the editing. This is a name:value pair array with additional pair id:rowid
After the row is saved or restored the editable attribute is set to “0” and the savedRow item with id=rowid is deleted

Display multiple new rows in Kendo Grid

I am doing an inline add using Kendo Grid, but on the server side I am actually creating multiple records. The DataSourceRequest sends back all the newly created rows, but only one is added to the grid. The other added records may not show up in the grid at all until the grid is forced to query for the data again.
Is there a way for me to add multiple rows at once?
If not, is there a way to re-query the data and put all newly added models at the top?
In my controller function that creates the new records, I am returning the following. "models" contains all of the newly created records:
return this.Json(models.ToDataSourceResult(request, this.ModelState), JsonRequestBehavior.AllowGet);
I also have a similar issue when updating a row since the server may actually update multiple rows. Since "models" contains multiple models, the first one in the list may or may not be the actual model selected to be updated, so sometimes a different edited model will replace the model that was selected to be updated in the grid.
Thanks,
Rob
I ended up using the kendo grid datasource insert method to add any records returned by my controller that were not already in the grid. I did this in the RequestEnd event for the datasource.
In order for this to work for inline adds, I needed to make sure the first model in the list returned by the controller was always the model being added by the grid. For some reason the initial model being added does not have an ID until the dataBinding event is reached which occurs after the RequestEnd event. So on adds, I simply ignore the first model in the results because it is already in the grid.
Also, when editing rows that are manually inserted into the datasource and then cancelling the edit, the grid removes them from the datasource. I had to block this using the preventDefault() function in the DataBinding event when a "remove" action was encountered directly after editing a row that I manually inserted into the datasource.

kendo dropdown list taking long time to load the options

I am developing a kendo grid in my HTML page (not MVC app) and it gets about 500+ records from the backend service. I have 4 Kendo dropdown lists in each row and 2 are getting values from local variables and other 2 are getting data from ajax calls.
When I try to edit any dropdown list, it goes to the editor function of the column, but takes long time to show the values in dropdown list and sometimes the IE page crashes. I am using IE11.
Do you have any best practices to work with Kendo dropdown list type if the grid has more records say > 200 records.
When I need to show that many results in a dropdown list I usually create an autocomplete combobox instead. You can show, for example, 10 results and have the server return more results as the user types.

Display the total number of rows in a Slickgrid table

Is there an accepted way to display the total number of rows in a slickgrid table. I see that there is a pager that I can include on my pages, but that comes with additional buttons/settings for pagination.
I am using a DataView object with no grouping. Ideally I'd like to simply have a trivial row at the bottom of the viewport that lists how many rows are in the table.
I could do this manually but wasn't sure if I was missing something in the Slickgrid APIs/configuration.
Use this method...to get number of rows displayed in the grid..(if no pagination is there)
grid.getDataLength();
if pagination is there....use this..
grid.getData().getPagingInfo().pageNum
grid.getData().getPagingInfo().pageSize
grid.getData().getPagingInfo().totalPages
grid.getData().getPagingInfo().totalRows // what u want
Use the onRowCountChanged for dataView argument in Slick Grid.
dataView.onRowCountChanged.subscribe(function (e,args)
{
$("#RowCount").text(args.current);
});

Resources