Forum

November 2nd, 2014
A A A
Avatar

Lost password?
Advanced Search

— Forum Scope —




— Match —





— Forum Options —





Minimum search word length is 3 characters - maximum search word length is 84 characters

The forums are currently locked and only available for read only access
sp_Feed Topic RSS sp_Related Related Topics sp_TopicIcon
Search does not work in JqGrid
27/08/2011
20:17
Avatar
yashmangupta
Singapore
Member
Members
Forum Posts: 6
Member Since:
26/08/2011
sp_UserOfflineSmall Offline

Hi,

I am not able to perform the search activity in the jqGrid. Can someone guide on whether do I need to write a separate SQL query. Currently I am using the below code

$(function(){

$("#list").jqGrid({

url:gridReload(),

datatype: 'xml',

mtype: 'POST',

colNames:['ID','Visible', 'Question Title','Type','Question Hint','Answer','Explanation','File Type', 'File Name'],

colModel :[

//{name: 'myac', width:50, fixed:true, sortable:false, resize:false, formatter:'actions', formatoptions:{keys:true}},

{name:'PK_QuestionTitleID', index:'PK_QuestionTitleID', width:55, sortable:true, align:'center'},

{name:'IsQuestionTitleActive', index:'IsQuestionTitleActive', width:50, sortable:true, align:'center'},

{name:'QuestionTitle', index:'QuestionTitle', width:200, align:'left', sortable:true},

{name:'AnswerOptionType', index:'AnswerOptionType', width:50, align:'center', sortable:true},

{name:'QuestionHint', index:'QuestionHint', width:150, align:'left'},

{name:'CorrectAnswers', index:'CorrectAnswers', width:150, sortable:true},

{name:'CorrectAnswerExplanation', index:'CorrectAnswerExplanation', width:150, sortable:true},

{name:'QuestionFileType', index:'QuestionFileType', width:60, sortable:true, align:'center'},

{name:'QuestionFileName', index:'QuestionFileName', width:120, sortable:false, align:'center'}

],

rowNum:2,

rowList:[10,20,30],

pager: '#pager',

sortname: 'PK_QuestionTitleID',

sortorder: 'asc',

viewrecords: true,

gridview: true,

caption: 'My First grid',

multiselect: false,

subgrid: true,

autowidth: true,

autosearch: true,

height: 300

}).navGrid('#pager',{edit:true,add:true,del:false, search:false})

// this function is to retrieve the value from the Grid

jQuery("#a1").click( function(){

var id = jQuery("#list").jqGrid('getGridParam','selrow');

if (id) {

var ret = jQuery("#list").jqGrid('getRowData',id);

alert("id="+ret.PK_QuestionTitleID+" invdate="+escape(ret.QuestionTitle)+"...");

} else { alert("Please select row");}

});

// this function is to call search box

jQuery("#bsdata").click(function(){

jQuery("#list").jqGrid('searchGrid',

{sopt:['cn','bw','eq','ne','lt','gt','ew']}

);

});

// this function is to show the searchboxes on top of the grid

jQuery("#list").jqGrid('filterToolbar','');

});

function gridReload()

{

var cd_mask = jQuery("#ProgramName").val();

jQuery("#list").jqGrid('setGridParam',{url:"fetchquestionsdata.asp?prid="+cd_mask+"&q=1",page:1}).trigger("reloadGrid");

}

Yashman Gupta

29/08/2011
18:39
Avatar
tony
Sofia, Bulgaria
Moderator
Members

Moderators
Forum Posts: 7721
Member Since:
30/10/2007
sp_UserOfflineSmall Offline

Hello,

Try this

function gridReload()

{

var cd_mask = jQuery("#ProgramName").val();

return "fetchquestionsdata.asp?prid="+cd_mask+"&q=1″;

}

Regards

For professional UI suites for Java Script and PHP visit us at our commercial products site - guriddo.net - by the very same guys that created jqGrid.

29/08/2011
20:45
Avatar
yashmangupta
Singapore
Member
Members
Forum Posts: 6
Member Since:
26/08/2011
sp_UserOfflineSmall Offline

Hi Tony,

I am using the below function to pass the value selected by the User from the dropdown. I commented the 2nd line in the below code and replaced it with the code suggested by you but still no luck.

There is no search code in the ASP page which pulls the data from database as my assumption is that since the data is written in XML format, then the search will be table bound instead of searching db again.

The below line I have replaced it with $("#list").jqGrid('filterToolbar', { stringResult: true, searchOnEnter: true, defaultSearch:"cn" });

// this function is to show the searchboxes on top of the grid

jQuery("#list").jqGrid('filterToolbar','');

function gridReload()

{

var cd_mask = jQuery("#ProgramName").val();

jQuery("#list").jqGrid('setGridParam',{url:"fetchquestionsdata.asp?prid="+cd_mask+"&q=1",page:1}).trigger("reloadGrid");

}

Appreciate your help Smile

Yashman Gupta

Forum Timezone: Europe/Sofia

Most Users Ever Online: 715

Currently Online:
88 Guest(s)

Currently Browsing this Page:
1 Guest(s)

Top Posters:

OlegK: 1255

markw65: 179

kobruleht: 144

phicarre: 132

YamilBracho: 124

Renso: 118

Member Stats:

Guest Posters: 447

Members: 11373

Moderators: 2

Admins: 1

Forum Stats:

Groups: 1

Forums: 8

Topics: 10592

Posts: 31289

Newest Members:

, razia, Prankie, psky, praveen neelam, greg.valainis@pa-tech.com

Moderators: tony: 7721, Rumen[Trirand]: 81

Administrators: admin: 66

Comments are closed.
Privacy Policy   Terms and Conditions   Contact Information