I want to show only specific row in my jqGrid table. I want to set a condition according to row ID. can any one have any solution for this?
Asked
Active
Viewed 2,354 times
0
-
Hi oleg, I am using xml data to show in treegrid and want to show only specific row data as per condition set by row ID. – manish987654321 Jul 25 '11 at 10:30
-
Do you get the XML data which generate the server or use static XML file or XML as string? Which `datatype` has the grid? An example of jqGrid and the data will be much better because there are too many possibilities. – Oleg Jul 25 '11 at 10:38
-
I am using static xml file. in which first row is rowid for the XML. – manish987654321 Jul 25 '11 at 11:02
-
Is the second grid a tree grid or not? Do you have different XML files for master and detailed grids? If the `topxml2.xml` is a static file than the appending of the `id=...` to the url would change nothing and the whole file will be loaded. So if I understand you correct the whole contain of the file will be loaded. So you want display only a part of the data. Where you find the information about the rowids which should be displayed in the second (detailed) grid? We send so many time to clear the question. Why you not just prepare **whole example of the test data and jqGrid which you use**? – Oleg Jul 25 '11 at 12:35
-
the xml file from [your first question](http://stackoverflow.com/questions/6578837/show-xml-in-tree-format-with-the-help-of-jqgrid-treegrid) is not in the form which could be displayed in the tree grid. I hope you know now how the XML file should looks like. See [here](http://stackoverflow.com/questions/5862336/jqgrid-autoloading-treegrid-issue/5867537#5867537) one from the possible examples. – Oleg Jul 25 '11 at 12:41
-
If you has example with one row in both master and detailed grid it is nothing to filter. In the example I see not that banana could show any details of an apple. The real example will make the tings clear the wrong unnatural example has no sense. It is still unclear the relationship between the data from the first and the second grid. So I suggest that you modify the text of your question so that other people as you can understand your problem and your current stay of the implementation. Without the information I can't spend my time more. Sorry. – Oleg Jul 25 '11 at 13:02
1 Answers
1
You can use $("#"+rowid).hide()
or $("#"+$.jgrid.jqID(rowid)).hide()
in case of the row id can has some special characters (see the old answer). You can hide the rows inside of the loadComplete
event for example. In case of usage of treegrid you should take in the consideration that in the way you should hide top level (level:0) of the nodes. One more option which you has is to delete the nodes with respect of delRowData or delTreeNode instead of hiding.
UPDATED: Sorry, but what you probably try to do is just to display a tree grid. The code should be something like this
jQuery(function () {
jQuery("#tree").jqGrid({
url: 'manish987654321.xml',
colNames: ['Inv No', 'Column 1', 'Column 2'],
colModel: [
{ name: 'id', index: 'id', width: 55, hidden: true },
{ name: 'column1', index: 'column1', width: 150 },
{ name: 'column2', index: 'column2', width: 100 }
],
rowNum: 10000,
viewrecords: true,
height: "auto",
caption: "Invoice Header",
treeGrid: true,
treeGridModel: 'adjacency',
treedatatype: "local",
ExpandColClick: true,
ExpandColumn: 'column1'
});
});
Which you can see live here. It display the tree grid which can be expanded to
-
can you give any function that if I put in my code such that when I pass any rowId, I should show data related to that rowid. – manish987654321 Jul 25 '11 at 11:19
-
@manish987654321: Like I wrote in my answer the `loadComplete` is the good place. I asked you many time about your test data and the jqGrid definition which you use. You can modify the text of your question and include the data inside. You can additionally include the list of rowids which corresponds to the rows which should be hidden. – Oleg Jul 25 '11 at 11:28
-
Hi oleg, I have modified the question. now can you tell me the solution for this? – manish987654321 Jul 25 '11 at 11:51
-
-
-
@manish987654321: I still can't understand your problem and the data which you included can't be used to reproduce your problem in any way. – Oleg Jul 25 '11 at 15:26
-
can you post a proper working example for master-detail table in www.ok-soft-gmbh.com where master table may be a treegrid, with url and datatype are xml file and xml type. please give a link for xml files also. – manish987654321 Jul 26 '11 at 04:45
-
@manish987654321: There are no difference between treegrid and other grid in the case. It is also absolutely unimportant from which data source the grids are filled. In the master grid you should use `onSelectRow` event and inside of the event handler set some parameter of the detailed grid. After that you should reload the second grid with the new parameters. See "Advanced" / "Master Detail" example from http://trirand.com/blog/jqgrid/jqgrid.html – Oleg Jul 26 '11 at 05:47
-
I am using the same example almost every thing is working fine data is loaded in first grid (master grid) but it's now working properly for details grid. can you post a link with working example of master detail grid and with xml input( data type and url). – manish987654321 Jul 26 '11 at 06:38
-
@manish987654321: http://trirand.com/blog/jqgrid/jqgrid.html contains a working example. The problem is in **your code**. If you want that somebody helps you **you should post the code which you currently use**. – Oleg Jul 26 '11 at 06:50
-
I havenot change that code too much except in three steps In master Grid I am defining url:'../xmlfiles/Topxml2.xml', datatype:xml", and in detail grid url:'../xmlfiles/Topxml.xml', datatype:xml", and in OnSelectRow instead of jQuery("#list10_d").jqGrid('setGridParam',{url:"subgrid.php?q=1& id="+ids,page:1}); this one I am using jQuery("#list10_d").jqGrid('setGridParam',{url:"../xmlfiles/Topxml2.xml&id="+ids,page:1}); only in these three places I have change the codes. – manish987654321 Jul 26 '11 at 06:59
-
@manish987654321: It has no sense if you post code fragments and pseudo data in your question. If your grid do not what you want, then there are some problems which you not see. In the case only full code and full data can help to solve the problem. Because you don't see the error you can't select the parts which you find suspected. – Oleg Jul 26 '11 at 08:01
-
@manish987654321: I need Topxml2.xml and Topxml3.xml to be able to reproduce your problem. – Oleg Jul 26 '11 at 08:29
-
@manish987654321: By the way the line `url:'../xmlfiles/Topxml3.xml’,` **has wrong `’` character which should be `'`**. Another string `url: ../xmlfiles/Topxml2.xml,` **has no quotes**. It should be `url: '../xmlfiles/Topxml2.xml',` – Oleg Jul 26 '11 at 09:20
-
I modify the code according to you. but the problem is still the same – manish987654321 Jul 26 '11 at 10:33
-
@manish987654321: The code from your question contain no changes. How many time I should ask you to post the Topxml2.xml and Topxml3.xml ???!!! Moreover **you should describe exactly which problem you has now**. What not work as expected? After that you should describe what you at the end want. You wrote that you want "show only specific row in jqGrid" and "to set a condition according to row ID". Which exactly condition you want set? Which rows you want show? – Oleg Jul 26 '11 at 11:03
-
I have posted the xml file both xml files are same only name is different. now my problem is when I am clicking on any row in master grid that correspondence row is not displaying in the detail table. how can I do this thing? like if i am clicking 2nd row in master table then only 2nd row in the detail table should displayed. but this is not happening, can you tell me where is the problem and what I should do for this? – manish987654321 Jul 26 '11 at 11:18
-
@manish987654321: I updated my answer corresponds to my understanding of your XML data and all other information which I have. I recommend you additionally use XML comments if you want include in XML file additional information which is not part of the data. See [here](http://www.ok-soft-gmbh.com/jqGrid/manish987654321.xml). – Oleg Jul 26 '11 at 12:33
-
That you post I am able to do that thing means showing xml file in tree format. but I want to make master detail table. My problem is "when I am clicking on any row in master grid that correspondence row is not displaying in the detail table. how can I do this thing? like if i am clicking 2nd row in master table then only 2nd row in the detail table should displayed. but this is not happening, can you tell me where is the problem and what I should do for this?" – manish987654321 Jul 27 '11 at 04:52
-
@manish987654321: What is the details for the selected row of the first grid? What you posted as the XML file had no relation to the jqGrid which you posted. Even the number of columns are different. So you should posted no garbage as the jqGrid code or as the XML data. If you modified one more time your question we can continue. – Oleg Jul 27 '11 at 05:47
-
in the invoice header table(master table) if I click on banana then in detail table only banana should be displayed. I want this type of display. I – manish987654321 Jul 27 '11 at 06:32
-
@manish987654321: You don't posted XML with details. Moreover it is much better to have one XML file with details for every item from the first table. In real example you will have of course a web service which provide the XML data based on the URL parameters. The web service get the information from the database. – Oleg Jul 27 '11 at 06:55
-
I don't want to use web services I simple fetch the row associated with the "banana" row and in detail table it should show only "banana". – manish987654321 Jul 27 '11 at 07:17
-
@manish987654321: Then you should just create one XML file with details for every item in the master grid. You can choose the name of the XML file which is constructed from any prefix and the id of the row from the master grid. So you can easy construct the url for the detailed grid in the event handler `onSelectRow` of the main grid. Of course you should modify you current buggy code which reload the detail grid only for ids (the rowid) equal to 0 (==null). – Oleg Jul 27 '11 at 07:23
-
that's problem that I don't know what code I should write there. can you make an example and post it. – manish987654321 Jul 27 '11 at 08:19
-
@manish987654321: could you describe which details has the items from the treegrid? For example which details has "banana" and which "apple" or "Tabel11"? – Oleg Jul 27 '11 at 09:11
-
I want to simply show, if I click on row containing "banana" in master table then in detail table; which have the same xml, should show only row containing "banana". – manish987654321 Jul 27 '11 at 09:17
-
@manish987654321: the same XML contain **no information about the details**. I don't understand what you really want. The posting here looks like the never ending story. It starts to seem to me, that you just scoff at me. – Oleg Jul 27 '11 at 09:45
-
can you post an example of master detail table with the above inputs in your website. It would be very useful for me. – manish987654321 Jul 27 '11 at 10:39
-
@manish987654321: I have to create an example every time. You have see example on the demo page, but you can't understand it and make the changes. Do you have real problem which you try to solve or you want just to play with jqGrid. What is your real problem? All what you posted till now looks like dummy data without any background. Do you have a real project where you try to use jqGrid? Or the all the communication is the waste of time? – Oleg Jul 27 '11 at 10:48
-
I am posting a snapshot of master-grid table. I want to show this type of output. when I click on banana in master table. I want only banana in grid table. – manish987654321 Jul 27 '11 at 12:02
-
@manish987654321: I see no sense in what you posted. You event not spend your time to change the headers of the columns... Which sense has to put in "Detailed" table **the same** information which one could see in the "Master" table? – Oleg Jul 27 '11 at 12:19
-
this is a dummy xml. I can't put here actual xml.even in actual xml case, output should be similar to this one only. – manish987654321 Jul 28 '11 at 03:48