Hi
When i try to use JQGrid and load values from server (JSON load) , everything seems to work fine except that any row i click ,only the first rwo is selected. Any pointers as to where i could be going wrong?
Thanks
Sunil
Typically the problem exist if the JSON data has duplicate in the ids. For example if you place the same id in every row posted from the server you will have exactly the same behavior which you describe.
Related
The Problem
I have a very complex, rather outdated jqgrid implementation that I'm upgrading to the latest free-jqgrid and we're having an issue in that after clearing the grid with unload, when we re-initialize the grid, the row ids are higher than they should be to start.
They seem to still be incrementing and not starting again. Are there some global counters I need to clear out to have the grid completely clear itself before we re-render it?
Grid Clear
if ( this.timesheet_grid ) {
this.timesheet_grid.grid.jqGrid( 'GridUnload' );
this.timesheet_grid.grid = null;
this.timesheet_grid = null;
Rows after GridUnload has been run
Shows an id like jqg56
Stuff I've Tried Since Posting
GridDestroy
clearGridBeforeUnload
SOLUTION
As #Oleg has suggested i simply needed to set the id attribute manually when processing the grid data.
I see that your incorrectly understand the meaning of rowids and the requirements for input data. I'm wonder especially about the suggestion of Tony to reset $.jgrid.guid. I find the suggestion very bad because it looks like a solution, but it can produce more seriously problems as the problems, which are solved!
First of all, it's important to understand what is rowid. Rowid is the values of id attribute of the grid rows: the id values of <tr> elements of the grid's body (see here). The rowid are used as a parameter of almost all callbacks and events of jqGrid. Because of that jqGrid must assign id attribute to every row and the input data of the grid have to contain rowid information! The existence of rowids is critical for working jqGrid. Only because of that jqGrid generates unique rowids in case of wrong input data. Alternative for generation of ids would be preventing creating the grid at all.
jqGrid tolerates the error with specifying the rowids in input data only for some simple grids, where one need just display some simple data and one never need to use rowids. If you use ids then you should fix the problem only in one way: you have to fix your input data. You can for example include id property with unique value in every element of input data. You should take in consideration that no id duplicates exist not only in the grid but on the whole HTML page. It's strictly recommended to use idPrefix option with unique value for every grid always if your HTML page have more as one grids (inclusive grid with subgrids).
Resetting of $.jgrid.guid is very dangerous and it can break functionality of jqGrid because of creating elements with duplicate id values. The property $.jgrid.guid is global. It's common over all grids and subgrids on the page. Simple subgrids scenario will produces id duplicates after you manually reset $.jgrid.guid. It will be used inside of $.jgrid.randId() method used in many places of jqGrid code. For example, the method addRow used by inlineNav uses the method.
I repeat my suggestion more clear once more. If you uses rowids or if the values of rowids are important for you in some way then you have to include id property to every item of input data. If some other property has already an unique value then you can add key: true in the corresponding column of colModel (one can use key: true in only one column). Alternatively, you can add prmNames: { id: "myId" } if myId property of input data contains unique rowid instead of default id property.
jqGrid uses common counter in order to be a sure that there will be no duplicate values when a build in id generator is used.
To reset the value you will need to set the guid parameter to 1 - i.e
$.jgrid.guid =1;
after you unload the grid
If the solution is based on the knowing the behavior of the product, then this is a good solution.
If we try to solve the problem, without to knowing the behavior - it is a dangerous solution.
It is very easy to say - this is bad solution and it is very very dangerous to use this solution - so my question is:
What is happen with the counter if the user reload the page under some conditions?
The answer is: the counter is reset and we go to the same situations which are described in the above answer.
I do know sometimes I need to think out of the box rather than sticking with that seem-impossible way out. I have to achieve a report (not complicated I guess, but for me I have no more idea how to get)
Well, the details are as follow:
The report is kind of invoice type.
Like an usual report, it has header, body and footer. In my scenario, there is no footer. Only the report header and the body. The header is ok. The Body consist of a table.
My data rows starts from row 3( because I add some content in row no 1, inside the list, as for row no 2, I have my table column header). So, actually my data row(which is directly retrieved from dataset) is at row no 3. The header repeat correctly. In fact, the table is displaying exactly as I wanted. I have two groups in my table. One is group by ItemCode, and then sort by ItemCode and Department number.
I have subtotal of value by ItemCode and Grandtotal after that. So, there are three rows for my data: one directly retrieved from dataset, one for subtotal and one for grandtotal. The problem is here:
I can't limit the number of row because of the groups. The row number rankings are messed up and that's why I can't limit. The resulting outcome is having inconsistency in showing numbers of rows.
For example I want to limit 10, but in some page, it displays 10(correct), but in the next page it might becomes 12 or 8 or even 4. That is one thing. Another is that I want to replace the missing rows(2 rows in this case) with blank rows if the it just displays only 8 rows(example). My idea is to maintain the same layout of the table in every page.
As for now, I have no more idea how to achieve my desired result. If I really cannot use row limit then how to do next. I have been researching about that for quite a long time, but still cannot get away with a solution.
I hope I have made myself clear explaining what is going on. Some part is not clear enough, then get back to me. I will try my best to explain more.
If anyone has any suggestions, please kindly share. Your help is much appreciated!
How do I get the search/filter to work per column?
I am making small steps in building, and constantly adding to my data table, which is pretty dynamic at this stage. It basically builds a datatable based on the dat that is fed into it. I have now added the footer to act as a search/filter, but unfortunately this is where I have become stuck. I cannot get the filer part to work. Advice greatly appreciated.
here is my sample data tables that I am working on http://live.datatables.net/qociwesi/2/edit
It basically has dTableControl object that builds by table.
To build my table I need to call loadDataFromSocket which does the following:
//then I have this function for loading my data and creating my tables
//file is an array of objects
//formatFunc is a function that formats the data in the data table, and is stored in options for passing to the dTableControl for formatting the datatable - not using this in this example
//ch gets the keys from file[0] which will be the channel headers
//then I add the headers
//then I add the footers
//then I create the table
//then i build the rows using the correct values from file
//then I draw and this then draws all the row that were built
//now the tricky part of applying the search to each columns
So i have got this far but the search per column is not working. How do I get the search/filter to wrok per column?
Note this is a very basic working example that I have been working off: http://jsfiddle.net/HattrickNZ/t12w3a65/
You should use t1.oTable to access DataTables API, see updated example for demonstration.
Please compare your code with jsFiddle in your question, notice its simplicity and consider rewriting your code.
I am using Slickgrid first time for CRUD table.
I am calling a rest service for data update from the function
grid.onCellChange.subscribe(function (e));
In this function, I want to get only changed columns/data.Right now, I am getting all of the data/columns for that row.
I am sure it is possible but I don't seem to find any method :(
This solved my problem:
item[grid.getColumns()[col].field]
I am working on jqGrid.I had a problem in the navigator rowList.
my data to this field is like this rowList:['25','50','75','-1'].
I am using -1 to display all the records.In the row list,i wish to use "All" instead of "-1" to display all the records is their any possibility to do this.
Thanks in advance.
Regards,
Phani Kumar
There are no All value as rowNum and in the rowList array. You should also not use -1 (see documentation about rowNum for example) or other negative values. The value -1 was allowed in some cases in the old releases of jqGrid, but it is no more supported in last releases. The value like 1000, 10000 are good enough depend on your requirements.
Having some realistic restrictions in the number of displayed rows is a good idea independent on the jqGrid support. No real user are able to examine 1000 rows of information without data paging, filtering (searching) or at least scrolling of the data in the web browser. So the displaying of about 50 or 100 row as maximum is what I would recommend you. Look at another old answer for more details and see included examples.