If I take Multi Search option I see lightning speed in rendering the page. i.e. I had only string fields to display
e:Â { name: ‘Turf’, width: 50, align: ‘center’ },
Where as when I add back search functionality it got slowed down
{ name: ‘Project’, width: 80, align: ‘center’, formatter: ‘select’,
edittype: ‘select’,
editoptions: {
value:uniqueprojectIds,
multiple: true
},
stype: ‘select’,
searchoptions: {
sopt: ,
value: uniqueprojectIds,
attr: { multiple: ‘multiple’, size: 4 },
dataInit: dataInitMultiselect
}
},
Â
Is there anything went wrong with this following code piece ? I appreciate your help
Â
$(function () {
‘use strict’;
$grid = $(“#list”),
myDefaultSearch = “cn”,
getColumnIndexByName = function (columnName) {
var cm = $(this).jqGrid(‘getGridParam’, ‘colModel’), i, l = cm.length;
for (i = 0; i < l; i += 1) {
if (cm.name === columnName) {
return i; // return the index
}
}
return -1;
},
modifySearchingFilter = function (separator) {
var i, l, rules, rule, parts, j, group, str, iCol, cmi, cm = this.p.colModel,
filters = $.parseJSON(this.p.postData.filters);
if (filters && filters.rules !== undefined && filters.rules.length > 0) {
rules = filters.rules;
for (i = 0; i < rules.length; i++) {
rule = rules;
iCol = getColumnIndexByName.call(this, rule.field);
cmi = cm[iCol];
if (iCol >= 0 &&
((cmi.searchoptions === undefined || cmi.searchoptions.sopt === undefined)
&& (rule.op === myDefaultSearch)) ||
(typeof (cmi.searchoptions) === “object” &&
$.isArray(cmi.searchoptions.sopt) &&
cmi.searchoptions.sopt[0] === rule.op)) {
// make modifications only for the ‘contains’ operation
parts = rule.data.split(separator);
if (parts.length > 1) {
if (filters.groups === undefined) {
filters.groups = [];
}
group = {
groupOp: ‘OR’,
groups: [],
rules: []
};
filters.groups.push(group);
for (j = 0, l = parts.length; j < l; j++) {
str = parts[j];
if (str) {
// skip empty ”, which exist in case of two separaters of once
group.rules.push({
data: parts[j],
op: rule.op,
field: rule.field
});
}
}
rules.splice(i, 1);
i–; // to skip i++
}
}
}
this.p.postData.filters = JSON.stringify(filters);
}
},
dataInitMultiselect = function (elem) {
setTimeout(function () {
var $elem = $(elem), id = elem.id,
inToolbar = typeof id === “string” && id.substr(0, 3) === “gs_”,
options = {
selectedList: 2,
height: “300”,
checkAllText: “all”,
uncheckAllText: “no”,
noneSelectedText: “Any”,
open: function () {
var $menu = $(“.ui-multiselect-menu:visible”);
$menu.width(“auto”);
return;
}
},
$options = $elem.find(“option”);
if ($options.length > 0 && $options[0].selected) {
$options[0].selected = false; // unselect the first selected option
}
if (inToolbar) {
options.minWidth = ‘auto’;
}
$elem.multiselect(options).multiselectfilter({ placeholder: ” });
$elem.siblings(‘button.ui-multiselect’).css({
width: inToolbar ? “98%” : “100%”,
marginTop: “1px”,
marginBottom: “1px”,
paddingTop: “3px”
});
}, 50);
};
@tony said:
Hello,Â
The reason for this can be 100.Â
The code you have posted is a very long, so it is very difficult to tell you where is the reason.
The reason can be on server query and etc.
Â
I recommend you to construct very very basic grid – only data and colmodel definition.
If the result is ok (quick load), then you can step by step add the other code in order to see where is the problem.
Â
Kind Regards
Thanks Tony…Infact I could  not post the whole content of the page as there is limitation on no. of characters to post. I have 45 columns (some strings and some dates)  to display and USERS wanted unique values to be displayed for multi select on each column and I believe I do not have any extra processing other than building the jQuery Grid. I sent emails with whole code in it. Could you please kindly check and let me know If I can improve on speedÂ
Is there anyway we can reload with filtered data on multiselect dropdown lists  ? We need this solution to be implemented ASAP. I would greatly appreciate if anyone can share the solution.
Eg : I have continents, Countries, States and Cities. I need to show USERS a filtered view when user chooses CONTINENT , I should display ONLY countries in the COUNTRY column  multiselect options and similarly it goes for states. I should not make server side call for each filter.  I am calling the following function from LOADCOMPLETE event of GRID but this is not working for the obvious reason mentioned in this thread.
Â
function setSearchSelect(columnName)
{
$(“#list”).jqGrid(‘setColProp’, columnName, {
editoptions: {
value: buildSearchSelect(getUniqueNames(columnName)),
multiple: true
},
searchoptions: {
sopt: ,
value: buildSearchSelect(getUniqueNames(columnName)),
attr: { multiple: ‘multiple’, size: 4 },
dataInit: dataInitMultiselect
}
}
);
}
Copyright 2014 TriRand LtdAll Rights ReservedRSS
Back to Top