Hello Tony,
I uploaded here the current version of columnChooser which I use. It is based on the current version of columnChooser on jqGrid. The changes are following
Short comment to the resizing code. The original structure of content of the Column Chooser dialog looks like on the picture

If we start from the .ui-dialog-content then
The code which I added in columnCooser at the end of the method changes CSS inline settings of the most above dives so that there have height: 100%; width: 100%; margin: auto. CSS of the right and the left pains (>div>.ui-multiselect>.selected and >div>.ui-multiselect>.available) will be set to width: 50%; box-sizing: border-box (width value will be calculated based on dividerLocation). After that the most elements of the dialog will be resized automatically correctly. One will just adjust the hight of ul elements (>div>div.ui-multiselect>div.selected>ul.selected and >div>div.ui-multiselect>div.available>ul.available). I did it inside of resize callback of the function dlog_opts.
The demo uses the code of new column chooser. Additionally is demonstrates usage of setColWidth method (see the answer and here). Tony you can include the method in the main code of jqGrid if you want. Additionally the demo demonstrates autosizeColumns function which works slowly, but it allows to set column widths based on the width of maximal content in the column and the column header. The requirement will be frequently asked. Probably the code could help other people.
Best regards
Oleg
P.S. I don’t tested the resizing code in old versions of web browsers. If the tests will show some problems in the browsers I would suggest to add if(old browser) return to skip resizing code. In the way one will have correct resizing in new web browsers and one will have old (non-resizable) Column Chooser dialog in old browsers.
It’s not a bug. jqGrid send always rowid parameter as id parameter. See the documentation. On the other side jqGrid provide you prmNames option which almost you to rename almost all parameter which will be sent by jqGrid to the server. By usage prmNames: { id: “myId” } will rename the id name used during editing (delete too) to myId.
One other thing, in small code fragment which you posted, looks not good: you use name having special meta-charackter “.” (see here). It’s not good. I would recommend you better to use name value which have no dots, spaces and other. Instead of that you can use typically jsonmap to read input JSON data, but you can still use name with more better value. Exact implementation could depends on other parameters which you use in jqGrid and from the exact format of input data. Just try to use
|
1 2 3 4 |
colModel: [<br /> { label: "ID", Â name: "id", Â jsonmap: "groups.id", key: true },<br /> { label: "Name", name: "name", jsonmap: "groups.name" }<br /> ] |
Best regards
Oleg
Hi Tony,
it seems to me that the CSS rules
|
1 2 3 |
.ui-search-menu.ui-menu .ui-menu-item { list-style-image: none; padding-right: 0; padding-left: 0; }<br /> .ui-search-menu.ui-menu .ui-menu-item a { display: block; }<br /> .ui-search-menu.ui-menu .ui-menu-item a.g-menu-item:hover { margin: -1px; font-weight: normal; } |
can fix the jQuery UI compatibility problems which I described in the previous post.
Best regards
Oleg
P.S. The pull request contains the changes.
I can confirm the bug. It’s important to mention that the problem don’t exist if one uses old versions of jQuery (for example 1.8.3) and old version of jQuery UI (for example 1.8.24). I prepared the demo which uses the old versions of jQuery and jQuery UI and it seems to work without any problems.
Then I get the last version of jQuery UI Multiselect plugin from github and made some small changes to use [selected] selector. I changed two lines of jqGrid code too to do the same. As the result the code seems to work for both new jQuery (1.11.1) and new jQuery UI (1.11.0): the new demo. It’s important to remark that the demo which uses modified ui.multiselect.js and modified jqGrid works with old versions of jQuery (1.8.3) and jQuery UI (1.8.24).
The modification which I made in jqGrid was replacing the line
|
1 |
if (this.selected) { |
to the line
|
1 |
if ($(this).is("[selected]")) { |
and replacing the line
|
1 |
$('option:selected',select).each(function() { perm.push(parseInt(this.value,10)); }); |
to the line
|
1 |
$('option[selected]',select).each(function() { perm.push(parseInt(this.value,10)); }); |
 In the same way I modified the lineÂ
|
1 |
var options = that.element.find('option').not(":selected"); |
of ui.multiselect.js to the following line
|
1 |
var options = that.element.find('option').not("[selected]"); |
and another linesÂ
|
1 2 3 |
var item = that._getOptionNode(this).appendTo(this.selected ? that.selectedList : that.availableList).show();<br /> <br /> if (this.selected) that.count += 1; |
to the lines
|
1 2 3 4 |
var isSelected = $(this).is("[selected]"),<br /> item = that._getOptionNode(this).appendTo(isSelected ? that.selectedList : that.availableList).show();<br /> <br /> if (isSelected) that.count += 1; |
One can get the modified version of ui.multiselect.js here.
Best regards
Oleg
I modified the demo: the original and “the improved”. Different web browsers shows different time, for example
IE11: original about 830, improved about 160,Â
IE10: original about 600, improved about 120,
Chrome 37.0.2062.103: original about 1050, improved about 130
In all tests the “improved” version worked noticeably quickly.
About your comment rather the problem is jQuery problem or jqGrid problem. I see the problem so. If jqGrid are used with data input parameter it’s not really required to make deep copy of it. My demos shows, that making deep copy of a array parameter could take relatively many time. The only parameter which can be really large is data parameter. If jqGrid will don’t use it in $.extend(true,{…}) then the code could be just more quickly. So I see the suggested change as performance optimization in jqGrid and not as workaround of some jQuery bug. One can suggest a lot of optimizations in jqGrid code, but the most from there will improve performance in less then 0,1%. What I suggest can improve loading of large grid in multiple times just by removing some operation (deep copy of data parameter) which are not really required for jqGrid.
Best regards
Oleg
P.S. I posted the pull request with the suggestions.
I want to add for better description of the problem that in case of jqModal: false jqGrid just add every time new Add/Edit form with the same ids and then shows the first form (because of usage of id selector in $.jgrid.viewModal / $.jgrid.hideModal which find the first element on the page with the id). As the result the HTML representation of grid after one click on Edit and another Click on Add look like

After repeat of Edit and Add clicks one will have 4Â forms with the same id and so on:

So it’s definitively a bug in jqGrid.
One more small problem in jqGrid in case of is the font-size value. The font size in the form will be specified byÂ
|
1 |
.ui-jqdialog {...} |
 CSS rule (see the line of ui.jqgrid.css). On the other size the rule will be overwritten by CSS rule
|
1 |
.ui-widget .ui-widget {font-size: 1em;} |
 of jQuery UI (see here). To fix the problem one should add additional CSS rule to ui.jqgrid.css:
|
1 |
.ui-jqgrid .ui-jqdialog { font-size:11px; } |
I hope that Tony will read the thread and will make the reported problems (recreateForm: true don’t remove old form, jqModal: false creates forms with id duplicates and opens always the first form, incorrect font-size in editing form in case of jqModal: false)
Best regards
Oleg
It seems to me that it’s really a bug in jqGrid. I will post later details. As a workaround I suggest to remove
|
1 |
jqModal: false |
option from editing options. One of the reason of the problem is that jqGrid 4.5.4 (previous version, before 4.6) had the linesÂ
|
1 2 3 |
if(p.recreateForm===true && $("#"+$.jgrid.jqID(IDs.themodal))[0] !== undefined) {<br /> $("#"+$.jgrid.jqID(IDs.themodal)).remove();<br /> } |
which are removed from jqGrid 4.6 because of some reasons. So recreateForm option don’t really work in jqGrid 4.6.
An alternative workaround would be to add beforeInitData callback in jQuery.jgrid.edit which would remove the previous created Edit/Add form:
|
1 2 3 |
beforeInitData: function () {<br /> $("#editmod" + this.id).remove();<br /> } |
Best regards
Oleg
If you use default options of jqGrid or use recreateForm: true only for Edit and not for Add then jqGrid works as following
If the user clicks Edit button the Edit form will be created. On closing the Edit form the form will be not destroyed, it will be just hidden (see here).
If the user clicks Add button later jqGrid test the recreateForm option of Add operation. If it’s true then the previous created Add/Edit form will be destroyed (just some form options will be saved before see the lines).
In general jqGrid try to modify Edit Form to Add form, but it works not always because of different reasons. So I personally recommend everybody to use recreateForm: true.
Do you tried the line
|
1 |
$("#itemsList").jqGrid('navGrid',"#itempager",{del:false,search:false},{recreateForm:true},{recreateForm:true}); |
 which I posted in one of my previous posts? Is the problem fixed now?
Best regards
Oleg
You still don’t answer on my previous questions:
The code which you posted contains exact the same Add and Edit options. So which problem you have exactly? How you see the differences?
Moreover you used recreateForm: true only for Edit and not for Add options. Setting of jQuery.extend(jQuery.jgrid.edit, {…}); would be more logically to do before navGrid.
Regards
Oleg
You still posted fragments of the code (the order could be important too for example). The code which you posted contains exact the same Add and Edit options. So which problem you have exactly? How you see the differences?
To be sure that the problem is do not recreateForm problem I would recommend you to try to replace navGrid call which you posted to the following
|
1 |
$("#itemsList").jqGrid('navGrid',"#itempager",{del:false,search:false},{recreateForm:true},{recreateForm:true}); |
I recommend you additionally to rewrite the code of serializeEditData. The current code is very dirty. Instead of appending elem in the way like you do you can use for example onclickSubmit callback
|
1 2 3 |
<span style="color: #333333">onclickSubmit: function () {<br /> </span> return {elem:Â $('[name=chkboxId]:checked').last().val()};<br /> } |
and uses justÂ
|
1 2 3 |
serializeEditData: function (postData) {<br />   return JSON.stringify(postData);<br /> } |
regards
Oleg
First of all you should always post more details about what you do. Which editing mode you use (form editing, inline editing, cell editing) and in which form (inline editing for example can be used by direct call of editRow, by usage inlineNav or by usage of formatter: “actions”).
If you use form editing for example then you can solve your problem probably by adding recreateForm: true option for both Add and Edit options.
Best regards
Oleg
Probably you posted in the wrong forum. jqGrid is jQuery plugin written in JavaScript. It’s open source and can be downloaded from trirand.com. There are some commercial solutions like from trirand.net for example. To understand the products good you still should have the knowledge of original JavaScript library, but you do many things in C# (or ASPX). You should read the corresponding documentation (like “Searching (Filtering) data” part of the documentation). In any way you should post your questions to the correct forum (for example here) and not in the current one.
Hi!
You can use some jQuery plugins or jQuery UI Widget to implement your requirement. One initialize the custom control/plugin/widget typically by calling some dataInit callback of searchoptions in the corresponding column of colModel.
Take a look in my old answers, which provides demos using jQuery UI MultiSelect Widget (get here the last version): this one, this one and another one.
Another way will be to use select2 plugin with the option multiple: true. It have another interface, but it can be used to implement multiselect too.
Best regards
Oleg
I posted before the suggestion (see the answer too) which describe how to make columnChooser resizable. The code still work. You can just include the code starting with $.jgrid.extend({columnChooser :function(opts){… from the answer and include the code fragment after jquery.jqGrid.min.js. In the way you will replace the original code of columnChooser with resazable version of it.
@Tony: probably one could do modify the original code of columnChooser in the way? I use the code in all my grids more as two years and I didn’t found any problem with the modified code which I suggested.
Best regards
Oleg
Copyright 2014 TriRand LtdAll Rights ReservedRSS
Back to Top