Forum


23:19

21/10/2008

hi
am using 3.4 version.am using asp as server side script. am not getting search parameters in server side.my code is
<html>
<head>
<title>jqGrid Demo</title>
<link rel="stylesheet" type="text/css" media="all" href="themes/coffee/grid.css" />
<link rel="stylesheet" type="text/css" media="all" href="themes/jqModal.css" />
<script src="jquery.js" type="text/javascript"></script>
<script src="jquery.jqGrid.js" type="text/javascript"></script>
<script src="js/jqModal.js" type="text/javascript"></script>
<script src="js/jqDnR.js" type="text/javascript"></script>
<script type="text/javascript">
var myGrid;
var lastSel;
jQuery(document).ready(function(){
var lastsel;
jQuery("#list").jqGrid({
url:'example.asp',
datatype: 'xml',
mtype: 'GET',
subGrid:true,
height:212,
colNames:['act','Sup Id','Name','ContactName','City', 'Country'],
colModel :[
{name:'act', index:'act', width:65, search:false},
{name:'SupplierID', index:'SupplierID', width:65, sorttype:'int'},
{name:'CompanyName', index:'CompanyName', width:250, editable: true, editoptions:{size:"20",maxlength:"30"}, sorttype:'int'},
{name:'ContactName', index:'ContactName', width:100, align:'right'},
{name:'City', index:'City', width:100, editable: true, search:false,edittype: "select", editoptions: {value: getValue() }},
{name:'Country', index:'Country', hidden: true, editable: true, editoptions:{size:"20",maxlength:"30"}, editrules:{edithidden:true, required:true}}
],
pager: jQuery('#pager'),
rowheight:'100%',
rowNum:5,
rowList:[10,20,30],
sortname: 'CompanyName',
sortorder: "desc",
viewrecords: true,
multiselect:true,
//cellEdit:true,
subGrid: true,
autosearch:false,
subGridUrl : "example11.asp",
subGridModel :[ { name: ['act', 'Sup', 'Name', 'ContactName', 'City','Country'],
width : [100, 100, 100,100, 100,100], params: ['SupplierID'] } ],
onSelectRow:
function(id){
if(id && id!==lastSel)
{
jQuery('#list').restoreRow(lastSel); lastSel=id; }
jQuery('#list').editRow(id, true);
},
/*onSelectRow: function(id){
var s;
s = jQuery("#list").getGridParam('selarrrow');
for(var i=0; i < s.length; i++)
{
if(s[i] && s[i]!==lastsel){
jQuery('#list').restoreRow(lastsel);
lastsel=s[i];
}
jQuery('#list').editRow(s[i],true);
}
}, */
loadComplete: function(){
var ids = jQuery("#list").getDataIDs();
for(var i=0;i<ids.length;i++){
var cl = ids[i];
be = "<input style='height:22px;width:20px;' type='button' value='E' onclick=jQuery('#list').editRow("+cl+"); >";
se = "<input style='height:22px;width:20px;' type='button' value='S' onclick=jQuery('#list').saveRow("+cl+"); />";
ce = "<input style='height:22px;width:20px;' type='button' value='C' onclick=jQuery('#list').restoreRow("+cl+"); />";
de = "<input style='height:22px;width:20px;' type='button' value='D' onclick=jQuery('#list').delGridRow("+cl+"); />";
jQuery("#list").setRowData(ids[i],{act:be+se+ce+de})
}
},
imgpath: 'themes/coffee/images',
caption: 'SUPPLIER TABLE'
}).navGrid('#pager',
{}, //options
{height:380, width: 500, reloadAfterSubmit:true}, // edit options
{height:280,reloadAfterSubmit:true, closeAfterAdd:true}, // add options
{height:180, width: 300, reloadAfterSubmit:true}, // del options
{} // search options
);
//jQuery("#t_s1list").height(25).hide().filterGrid("#list",{gridModel:true,gridToolbar:true});
jQuery.jgrid.del = {
top:100,left:700,
url: 'delete.asp',
caption: "MKP Delete",
msg: "Delete selected record(sss)?",
bSubmit: "Delete Rec",
bCancel: "Cancel",
processData: "Processing..."
//afterSubmit: function(msg){alert("asdasd"); return true;}
};
jQuery.jgrid.edit = {
url: 'edit.asp',
editCaption: "Edit Record",
addCaption: "Add Record",
msg: "Edit selected record(s)?",
bSubmit: "Save",
bCancel: "Cancel",
postData:[{Country:'India'}],
processData: "Processing..."
//afterSubmit: function(msg){alert("asdasd"); return true;}
};
jQuery("#list").sortGrid("CompanyName",true);
$("#srccontents").filterGrid(
"#list",
{ gridModel:true,
gridNames:true,
formtype:"vertical",
enableSearch:true,
enableClear: true,
autosearch: false,
afterSearch : function() {
// jQuery(".HeaderButton").trigger("click");
}
});
//var addprm = { width: 450, height: 200, top: 125, left: 50, reloadAfterSubmit:true, closeAfterAdd:true };
/*
jQuery.jgrid.search = {
url: 'example.asp?q=1',
caption: "Search Record...",
Find: "Search",
Reset: "Reset",
odata: ['equal', 'not equal', 'less', 'less or equal','greater','greater or equal', 'begins with','ends with','contains' ] ,
sopt: null
}
//$.extend($.jgrid.search,{Find:'Search'})
jQuery("#list").searchGrid({
caption: "Search Recordsss...",
Find: "Search111",
Reset: "Reset111",
odata: ['equal', 'not equal', 'less', 'less or equal','greater','greater or equal', 'begins with','ends with','contains' ] ,
sopt: null
})
*/
});
function checksave(result) {
if (result=="") {alert("Update is missing!"); return false;}
return true;
}
function getValue(){
var html1 = $.ajax({
url: "select.asp",
async: false
}).responseText;
return html1;
}
</script>
</head>
<body>
<div id="srccontents" height="300px"></div>
<table id="list" class="scroll" cellpadding="0" cellspacing="0"></table>
<div id="pager" class="scroll" style="text-align:center;"></div>
</body>
</html>
serverside code
<%@ language=vbscript codepage=65001 %>
<% Option Explicit %>
<!--#include file = "include/cache.asp" -->
<!--#include file = "include/connection.asp" -->
<%
Response.ContentType = "text/xml;charset=utf-8"
Dim page
Dim limit
Dim sidx
Dim sord
Dim movepage
' Get the requested page. By default grid sets this to 1.
page = Request("page")
'page = 1
movepage = Request("movepage")
' get how many rows we want to have into the grid - rowNum parameter in the grid
limit = Request("rows")
'limit = 10
' get index row - i.e. user click to sort. At first time sortname parameter - ' after that the index from colModel
sidx = Request("sidx")
' sorting order - at first time sortorder
sord = Request("sord")
' if we not pass at first time index use the first column for the index or what you want
if (Request("sidx") = "") then
sidx = 3
end if
Dim result
result = CSCount()
Dim count
count = result
Dim total_pages
Dim start
if (count > 0) then
total_pages = cInt(count/limit)
else
total_pages = 0
end if
if (cInt(page) > cInt(total_pages)) then
page = total_pages
end if
start = (limit * page) - limit
if (start < 0) then
start = 0
end if
'if (page = 1) then
'start = 0
'end if
'--------------------------------------------------------------------------------------------------------
Function CSCount()
Dim objDb
Dim strQuery
Dim arrRecords
Set objDb = Server.CreateObject("WComponents.DBAccess")
objDb.Init(Me)
objDb.DbConnection = Connection
objDb.AllowCloseConnection = False
objDb.ShowErrorMessage = True
strQuery = " SELECT COUNT(SupplierID) FROM Suppliers"
objDb.Sql = strQuery
arrRecords = objDb.Execute()
Set objDb = Nothing
CSCount = arrRecords(0,0)
End Function
'--------------------------------------------------------------------------------------------------------
Dim objDb
Dim strQuery
Dim arrRecords
Dim intI
Dim x
x = cInt(limit) + cInt(start)
Set objDb = Server.CreateObject("WComponents.DBAccess")
objDb.Init(Me)
objDb.DbConnection = Connection
objDb.AllowCloseConnection = False
objDb.ShowErrorMessage = True
strQuery = " SELECT * " & _
" FROM (SELECT TOP " & limit & " * " & _
" FROM (SELECT TOP " & x & " SupplierID, CompanyName, ContactName, City " & _
" FROM Suppliers " & _
" ORDER BY SupplierID DESC) a " & _
" ORDER BY SupplierID ASC) b " & _
" ORDER BY SupplierID DESC"
'strQuery
objDb.Sql = strQuery
arrRecords = objDb.Execute()
if(objDb.recordCount>0)then
response.write "<?xml version='1.0' encoding='utf-8'?>"
response.write "<rows>"
response.write "<page>"&page&"</page>"
response.write "<total>"&total_pages&"</total>"
response.write "<records>"&count&"</records>"
'response.write "<mpage>"&page&"</mpage>"
For intI = 0 to objDb.recordCount - 1
response.write "<row id='"& arrRecords(0,intI) &"'>"
response.write "<cell></cell>"
response.write "<cell>"& arrRecords(0,intI) &"</cell>"
response.write "<cell>"& arrRecords(1,intI) &"</cell>"
response.write "<cell>"& arrRecords(2,intI) &"</cell>"
response.write "<cell>"& arrRecords(3,intI) &"</cell>"
response.write "</row>"
Next
response.write "</rows>"
end if
Set objDb = Nothing
%>
03:44

Moderators
30/10/2007

Hello,
In which portion this does not work? I see multiple calls to filterGrid (one is commented and you have only object here)
Regards
Tony
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.
06:40

Moderators
30/10/2007

Hello,
If you have FireBug, see what is posted to the server or better read first the docs.
You should obtain the follwing parameters
searchOper, searchField, searchString
Regards
Tony
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.
13:00

24/04/2009

Default string is searchField e and not sField. I can' t find this in documentation, only when i get the request.query collection i see.
you need get
page=request.QueryString("page")
pNumPerPage=request.QueryString("rows")
sidx = request.QueryString("sidx")
sord = request.QueryString("sord")
'--------------------strings for search --------------------------------------------
sField=request.QueryString("searchField") '
sValue=request.QueryString("searchString")
vOperacao=request.QueryString("searchOper")
vProcura=request.QueryString("_search") ' return true if is search is present
Most Users Ever Online: 715
Currently Online:
101 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.comModerators: tony: 7721, Rumen[Trirand]: 81
Administrators: admin: 66