Jqgrid dynamic filter with url data source
I have a Jqgrid as follows:
jQuery("#jQGridDemo").jqGrid({
url: 'http://localhost:58404/JQGridHandler.ashx',
colNames: ['Property ID', 'Property Ref', 'Short Address', 'Scheme Code', 'Scheme Name', 'Property Type', 'Tenure Type', 'Status', 'Management Cost','Rent Charge Month','SC Charge Month'],
colModel: [
{ name: 'PropertyID', index: 'PropertyID', width: 70, align: "left", stype: 'text', sortable: true},
{name: 'PropertyType',width: 80},
{ name: 'TenureType', index: 'TenureType', width: 80, align: "center", sortable: true },
{ name: 'Status', index: 'Status', width: 75, align: "center", sortable: true },
],
The grid works and is populated with the Json returned from the URL.
However, I am trying to implement a dynamically populated drop-down-filter on the PropertyType column and have been looking at Oleg's answer here: How to add dynamic filter drop down using Jqgrid?
I have therefore added a "beforeProcessing" function:
beforeProcessing: function (data) {
var propertyMap = {}, propertyValues = ":All", rows = data.rows, i, symbol;
for (i = 0; i < rows.length; i++) {
symbol = rows[i].Symbol;
if (!propertyMap.hasOwnProperty(symbol)) {
propertyMap[symbol] = 1;
propertyValues += ";" + symbol + ":" + symbol;
}
}
$(this).jqGrid("setColProp", 'PropertyType', {
stype: "select",
searchoptions: {
value: propertyValues
}
}).jqGrid('destroyFilterToolbar')
.jqGrid('filterToolbar', {
stringResult: true,
searchOnEnter: false,
defaultSearch: "cn"
});
},
My question is, how do I pass the data returned from the URL to the "beforeProcessing: function (data)" -
Any help would be appreciated.
filter drop-down-menu jqgrid
|
show 3 more comments
I have a Jqgrid as follows:
jQuery("#jQGridDemo").jqGrid({
url: 'http://localhost:58404/JQGridHandler.ashx',
colNames: ['Property ID', 'Property Ref', 'Short Address', 'Scheme Code', 'Scheme Name', 'Property Type', 'Tenure Type', 'Status', 'Management Cost','Rent Charge Month','SC Charge Month'],
colModel: [
{ name: 'PropertyID', index: 'PropertyID', width: 70, align: "left", stype: 'text', sortable: true},
{name: 'PropertyType',width: 80},
{ name: 'TenureType', index: 'TenureType', width: 80, align: "center", sortable: true },
{ name: 'Status', index: 'Status', width: 75, align: "center", sortable: true },
],
The grid works and is populated with the Json returned from the URL.
However, I am trying to implement a dynamically populated drop-down-filter on the PropertyType column and have been looking at Oleg's answer here: How to add dynamic filter drop down using Jqgrid?
I have therefore added a "beforeProcessing" function:
beforeProcessing: function (data) {
var propertyMap = {}, propertyValues = ":All", rows = data.rows, i, symbol;
for (i = 0; i < rows.length; i++) {
symbol = rows[i].Symbol;
if (!propertyMap.hasOwnProperty(symbol)) {
propertyMap[symbol] = 1;
propertyValues += ";" + symbol + ":" + symbol;
}
}
$(this).jqGrid("setColProp", 'PropertyType', {
stype: "select",
searchoptions: {
value: propertyValues
}
}).jqGrid('destroyFilterToolbar')
.jqGrid('filterToolbar', {
stringResult: true,
searchOnEnter: false,
defaultSearch: "cn"
});
},
My question is, how do I pass the data returned from the URL to the "beforeProcessing: function (data)" -
Any help would be appreciated.
filter drop-down-menu jqgrid
It is already passed. Not Sure that I understand. To this event is passed the data from the server before it is inserted into the grid. Also there are some differences in different jqGrid versions regarding this event - actually which version of jqGrid is used - Guriddo jqGrid, free-jqGrid or jqGrid <= 4.7?
– Tony Tomov
Nov 23 '18 at 20:26
I am using version 4.5.1. The debugger is telling me that rows is null. So I assume the data is not being passed to the function before it is inserted into the grid.
– Sanxion
Nov 26 '18 at 10:48
What is your datatype? If the datatype is local it will not be passed in version 4.5. For this version the data is passed only if the datatype is json or xml. The problem does not exist in Guriddo jqGrid versions.
– Tony Tomov
Nov 26 '18 at 11:55
My datatype is Json.
– Sanxion
Nov 26 '18 at 12:05
try to console.log the data. It is possible that data.rows property does not exist according to the jsonReader . just before the rows = data.rows. make a console.log of data only
– Tony Tomov
Nov 26 '18 at 12:39
|
show 3 more comments
I have a Jqgrid as follows:
jQuery("#jQGridDemo").jqGrid({
url: 'http://localhost:58404/JQGridHandler.ashx',
colNames: ['Property ID', 'Property Ref', 'Short Address', 'Scheme Code', 'Scheme Name', 'Property Type', 'Tenure Type', 'Status', 'Management Cost','Rent Charge Month','SC Charge Month'],
colModel: [
{ name: 'PropertyID', index: 'PropertyID', width: 70, align: "left", stype: 'text', sortable: true},
{name: 'PropertyType',width: 80},
{ name: 'TenureType', index: 'TenureType', width: 80, align: "center", sortable: true },
{ name: 'Status', index: 'Status', width: 75, align: "center", sortable: true },
],
The grid works and is populated with the Json returned from the URL.
However, I am trying to implement a dynamically populated drop-down-filter on the PropertyType column and have been looking at Oleg's answer here: How to add dynamic filter drop down using Jqgrid?
I have therefore added a "beforeProcessing" function:
beforeProcessing: function (data) {
var propertyMap = {}, propertyValues = ":All", rows = data.rows, i, symbol;
for (i = 0; i < rows.length; i++) {
symbol = rows[i].Symbol;
if (!propertyMap.hasOwnProperty(symbol)) {
propertyMap[symbol] = 1;
propertyValues += ";" + symbol + ":" + symbol;
}
}
$(this).jqGrid("setColProp", 'PropertyType', {
stype: "select",
searchoptions: {
value: propertyValues
}
}).jqGrid('destroyFilterToolbar')
.jqGrid('filterToolbar', {
stringResult: true,
searchOnEnter: false,
defaultSearch: "cn"
});
},
My question is, how do I pass the data returned from the URL to the "beforeProcessing: function (data)" -
Any help would be appreciated.
filter drop-down-menu jqgrid
I have a Jqgrid as follows:
jQuery("#jQGridDemo").jqGrid({
url: 'http://localhost:58404/JQGridHandler.ashx',
colNames: ['Property ID', 'Property Ref', 'Short Address', 'Scheme Code', 'Scheme Name', 'Property Type', 'Tenure Type', 'Status', 'Management Cost','Rent Charge Month','SC Charge Month'],
colModel: [
{ name: 'PropertyID', index: 'PropertyID', width: 70, align: "left", stype: 'text', sortable: true},
{name: 'PropertyType',width: 80},
{ name: 'TenureType', index: 'TenureType', width: 80, align: "center", sortable: true },
{ name: 'Status', index: 'Status', width: 75, align: "center", sortable: true },
],
The grid works and is populated with the Json returned from the URL.
However, I am trying to implement a dynamically populated drop-down-filter on the PropertyType column and have been looking at Oleg's answer here: How to add dynamic filter drop down using Jqgrid?
I have therefore added a "beforeProcessing" function:
beforeProcessing: function (data) {
var propertyMap = {}, propertyValues = ":All", rows = data.rows, i, symbol;
for (i = 0; i < rows.length; i++) {
symbol = rows[i].Symbol;
if (!propertyMap.hasOwnProperty(symbol)) {
propertyMap[symbol] = 1;
propertyValues += ";" + symbol + ":" + symbol;
}
}
$(this).jqGrid("setColProp", 'PropertyType', {
stype: "select",
searchoptions: {
value: propertyValues
}
}).jqGrid('destroyFilterToolbar')
.jqGrid('filterToolbar', {
stringResult: true,
searchOnEnter: false,
defaultSearch: "cn"
});
},
My question is, how do I pass the data returned from the URL to the "beforeProcessing: function (data)" -
Any help would be appreciated.
filter drop-down-menu jqgrid
filter drop-down-menu jqgrid
asked Nov 23 '18 at 8:31
SanxionSanxion
54
54
It is already passed. Not Sure that I understand. To this event is passed the data from the server before it is inserted into the grid. Also there are some differences in different jqGrid versions regarding this event - actually which version of jqGrid is used - Guriddo jqGrid, free-jqGrid or jqGrid <= 4.7?
– Tony Tomov
Nov 23 '18 at 20:26
I am using version 4.5.1. The debugger is telling me that rows is null. So I assume the data is not being passed to the function before it is inserted into the grid.
– Sanxion
Nov 26 '18 at 10:48
What is your datatype? If the datatype is local it will not be passed in version 4.5. For this version the data is passed only if the datatype is json or xml. The problem does not exist in Guriddo jqGrid versions.
– Tony Tomov
Nov 26 '18 at 11:55
My datatype is Json.
– Sanxion
Nov 26 '18 at 12:05
try to console.log the data. It is possible that data.rows property does not exist according to the jsonReader . just before the rows = data.rows. make a console.log of data only
– Tony Tomov
Nov 26 '18 at 12:39
|
show 3 more comments
It is already passed. Not Sure that I understand. To this event is passed the data from the server before it is inserted into the grid. Also there are some differences in different jqGrid versions regarding this event - actually which version of jqGrid is used - Guriddo jqGrid, free-jqGrid or jqGrid <= 4.7?
– Tony Tomov
Nov 23 '18 at 20:26
I am using version 4.5.1. The debugger is telling me that rows is null. So I assume the data is not being passed to the function before it is inserted into the grid.
– Sanxion
Nov 26 '18 at 10:48
What is your datatype? If the datatype is local it will not be passed in version 4.5. For this version the data is passed only if the datatype is json or xml. The problem does not exist in Guriddo jqGrid versions.
– Tony Tomov
Nov 26 '18 at 11:55
My datatype is Json.
– Sanxion
Nov 26 '18 at 12:05
try to console.log the data. It is possible that data.rows property does not exist according to the jsonReader . just before the rows = data.rows. make a console.log of data only
– Tony Tomov
Nov 26 '18 at 12:39
It is already passed. Not Sure that I understand. To this event is passed the data from the server before it is inserted into the grid. Also there are some differences in different jqGrid versions regarding this event - actually which version of jqGrid is used - Guriddo jqGrid, free-jqGrid or jqGrid <= 4.7?
– Tony Tomov
Nov 23 '18 at 20:26
It is already passed. Not Sure that I understand. To this event is passed the data from the server before it is inserted into the grid. Also there are some differences in different jqGrid versions regarding this event - actually which version of jqGrid is used - Guriddo jqGrid, free-jqGrid or jqGrid <= 4.7?
– Tony Tomov
Nov 23 '18 at 20:26
I am using version 4.5.1. The debugger is telling me that rows is null. So I assume the data is not being passed to the function before it is inserted into the grid.
– Sanxion
Nov 26 '18 at 10:48
I am using version 4.5.1. The debugger is telling me that rows is null. So I assume the data is not being passed to the function before it is inserted into the grid.
– Sanxion
Nov 26 '18 at 10:48
What is your datatype? If the datatype is local it will not be passed in version 4.5. For this version the data is passed only if the datatype is json or xml. The problem does not exist in Guriddo jqGrid versions.
– Tony Tomov
Nov 26 '18 at 11:55
What is your datatype? If the datatype is local it will not be passed in version 4.5. For this version the data is passed only if the datatype is json or xml. The problem does not exist in Guriddo jqGrid versions.
– Tony Tomov
Nov 26 '18 at 11:55
My datatype is Json.
– Sanxion
Nov 26 '18 at 12:05
My datatype is Json.
– Sanxion
Nov 26 '18 at 12:05
try to console.log the data. It is possible that data.rows property does not exist according to the jsonReader . just before the rows = data.rows. make a console.log of data only
– Tony Tomov
Nov 26 '18 at 12:39
try to console.log the data. It is possible that data.rows property does not exist according to the jsonReader . just before the rows = data.rows. make a console.log of data only
– Tony Tomov
Nov 26 '18 at 12:39
|
show 3 more comments
1 Answer
1
active
oldest
votes
In case your data does not have a rows property you can modifiy your initial code like this:
beforeProcessing: function (data) {
var propertyMap = {}, propertyValues = ":All", rows = data, i, symbol;
for (i = 0; i < rows.length; i++) {
symbol = rows[i].Symbol;
if (!propertyMap.hasOwnProperty(symbol)) {
propertyMap[symbol] = 1;
propertyValues += ";" + symbol + ":" + symbol;
}
}
....
The only that differ from your original code is replacing
rows = data.rows
with
rows = data,
Thanks. That one change has made all the difference. I am new to the Jqgrid. Which version would you recommend I use?
– Sanxion
Nov 26 '18 at 14:45
It depends what you expect. You can use our commercial version Guriddo jqGrid with guaranteed support and development or you can use the open source fork free-jqGrid which has only support from Oleg without future Development
– Tony Tomov
Nov 26 '18 at 14:55
add a comment |
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53443078%2fjqgrid-dynamic-filter-with-url-data-source%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
In case your data does not have a rows property you can modifiy your initial code like this:
beforeProcessing: function (data) {
var propertyMap = {}, propertyValues = ":All", rows = data, i, symbol;
for (i = 0; i < rows.length; i++) {
symbol = rows[i].Symbol;
if (!propertyMap.hasOwnProperty(symbol)) {
propertyMap[symbol] = 1;
propertyValues += ";" + symbol + ":" + symbol;
}
}
....
The only that differ from your original code is replacing
rows = data.rows
with
rows = data,
Thanks. That one change has made all the difference. I am new to the Jqgrid. Which version would you recommend I use?
– Sanxion
Nov 26 '18 at 14:45
It depends what you expect. You can use our commercial version Guriddo jqGrid with guaranteed support and development or you can use the open source fork free-jqGrid which has only support from Oleg without future Development
– Tony Tomov
Nov 26 '18 at 14:55
add a comment |
In case your data does not have a rows property you can modifiy your initial code like this:
beforeProcessing: function (data) {
var propertyMap = {}, propertyValues = ":All", rows = data, i, symbol;
for (i = 0; i < rows.length; i++) {
symbol = rows[i].Symbol;
if (!propertyMap.hasOwnProperty(symbol)) {
propertyMap[symbol] = 1;
propertyValues += ";" + symbol + ":" + symbol;
}
}
....
The only that differ from your original code is replacing
rows = data.rows
with
rows = data,
Thanks. That one change has made all the difference. I am new to the Jqgrid. Which version would you recommend I use?
– Sanxion
Nov 26 '18 at 14:45
It depends what you expect. You can use our commercial version Guriddo jqGrid with guaranteed support and development or you can use the open source fork free-jqGrid which has only support from Oleg without future Development
– Tony Tomov
Nov 26 '18 at 14:55
add a comment |
In case your data does not have a rows property you can modifiy your initial code like this:
beforeProcessing: function (data) {
var propertyMap = {}, propertyValues = ":All", rows = data, i, symbol;
for (i = 0; i < rows.length; i++) {
symbol = rows[i].Symbol;
if (!propertyMap.hasOwnProperty(symbol)) {
propertyMap[symbol] = 1;
propertyValues += ";" + symbol + ":" + symbol;
}
}
....
The only that differ from your original code is replacing
rows = data.rows
with
rows = data,
In case your data does not have a rows property you can modifiy your initial code like this:
beforeProcessing: function (data) {
var propertyMap = {}, propertyValues = ":All", rows = data, i, symbol;
for (i = 0; i < rows.length; i++) {
symbol = rows[i].Symbol;
if (!propertyMap.hasOwnProperty(symbol)) {
propertyMap[symbol] = 1;
propertyValues += ";" + symbol + ":" + symbol;
}
}
....
The only that differ from your original code is replacing
rows = data.rows
with
rows = data,
answered Nov 26 '18 at 14:19
Tony TomovTony Tomov
1,6051710
1,6051710
Thanks. That one change has made all the difference. I am new to the Jqgrid. Which version would you recommend I use?
– Sanxion
Nov 26 '18 at 14:45
It depends what you expect. You can use our commercial version Guriddo jqGrid with guaranteed support and development or you can use the open source fork free-jqGrid which has only support from Oleg without future Development
– Tony Tomov
Nov 26 '18 at 14:55
add a comment |
Thanks. That one change has made all the difference. I am new to the Jqgrid. Which version would you recommend I use?
– Sanxion
Nov 26 '18 at 14:45
It depends what you expect. You can use our commercial version Guriddo jqGrid with guaranteed support and development or you can use the open source fork free-jqGrid which has only support from Oleg without future Development
– Tony Tomov
Nov 26 '18 at 14:55
Thanks. That one change has made all the difference. I am new to the Jqgrid. Which version would you recommend I use?
– Sanxion
Nov 26 '18 at 14:45
Thanks. That one change has made all the difference. I am new to the Jqgrid. Which version would you recommend I use?
– Sanxion
Nov 26 '18 at 14:45
It depends what you expect. You can use our commercial version Guriddo jqGrid with guaranteed support and development or you can use the open source fork free-jqGrid which has only support from Oleg without future Development
– Tony Tomov
Nov 26 '18 at 14:55
It depends what you expect. You can use our commercial version Guriddo jqGrid with guaranteed support and development or you can use the open source fork free-jqGrid which has only support from Oleg without future Development
– Tony Tomov
Nov 26 '18 at 14:55
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53443078%2fjqgrid-dynamic-filter-with-url-data-source%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
It is already passed. Not Sure that I understand. To this event is passed the data from the server before it is inserted into the grid. Also there are some differences in different jqGrid versions regarding this event - actually which version of jqGrid is used - Guriddo jqGrid, free-jqGrid or jqGrid <= 4.7?
– Tony Tomov
Nov 23 '18 at 20:26
I am using version 4.5.1. The debugger is telling me that rows is null. So I assume the data is not being passed to the function before it is inserted into the grid.
– Sanxion
Nov 26 '18 at 10:48
What is your datatype? If the datatype is local it will not be passed in version 4.5. For this version the data is passed only if the datatype is json or xml. The problem does not exist in Guriddo jqGrid versions.
– Tony Tomov
Nov 26 '18 at 11:55
My datatype is Json.
– Sanxion
Nov 26 '18 at 12:05
try to console.log the data. It is possible that data.rows property does not exist according to the jsonReader . just before the rows = data.rows. make a console.log of data only
– Tony Tomov
Nov 26 '18 at 12:39