Forum


I'm new to jquery/ jqgrid. I've got the basic grid working with my data but I'm stumped on providing extra filtering to my CFC. I need to pass in extra variables [myacct] to the query besides the grid info. I don't know where to put the variable in the grid.
This is my grid:
<script>
$(document).ready(function()
{
$("#list").jqGrid(
{
url:'Users.cfc?method=GetAllCases', //CFC that will return the users
datatype: 'json', //We specify that the datatype we will be using will be JSON
colNames:['ID','Case Number','Site ID','Site Name'], //Column Names
//The Column Model to define the data. Note you can make columns non sortable, specify width, alignment, etc.
// [#objid#,#x_account_id#,#x_site_id#,#x_site_name#]>
colModel :[
{name:'objid',index:'objid', width:50, sorttype:"int"},
{name:'x_object_id',index:'x_object_id', width:150, sorttype:"string"},
{name:'x_site_id',index:'x_site_id', width:150, align:"left",sorttype:"string"},
{name:'x_site_name',index:'x_site_name', width:150, align:"left",sorttype:"string"}
//{name:'UserName',index:'UserName', width:150,align:"left",sorttype:"string"},
//{name:'UserAccountingCode',index:'UserAccountingCode', width:150, sortable:false},
//{name:'Phone',index:'Phone', width:150, sortable:false}
],
pager: $('#pager'), //The div we have specified, tells jqGrid where to put the pager
rowNum:20, //Number of records we want to show per page
rowList:[4,8,12], //Row List, to allow user to select how many rows they want to see per page
sortorder: "desc", //Default sort order
sortname: "ID", //Default sort column
myacct: "268440464", // my account
//myDSN: "ClarifySMST", // pass in required vars
viewrecords: true, //Shows the nice message on the pager
imgpath: 'themes/coffee/images', //Image path for prev/next etc images
caption: 'Open Cases', //Grid Name
height:'auto', //I like auto, so there is no blank space between. Using a fixed height can mean either a scrollbar or a blank space before the pager
recordtext:'Total Records', //On the demo you will notice "7 Total Records" - The Total Reocrds text comes from here
pgtext:'of',//You notice the 1/3, you can change the /. You can make it say 1 of 3
editurl:"Users.cfc?method=GetAllCases",//Not used right now.
toolbar:[true,"top"],//Shows the toolbar at the top. I will decide if I need to put anything in there later.
//The JSON reader. This defines what the JSON data returned from the CFC should look like
jsonReader: {
root: "ROWS",
page: "PAGE",
total: "TOTAL",
records:"RECORDS",
cell: "",
id: "0"
}
}
);
}
);
</script>
This is my CFC:
<cffunction name="GetAllCases" access="remote" returnformat="json">
<cfargument name="page" required="no" default="1" hint="Page user is on">
<cfargument name="rows" required="no" default="15" hint="Number of Rows to display per page">
<cfargument name="sidx" required="no" default="" hint="Sort Column">
<cfargument name="sord" required="no" default="ASC" hint="Sort Order">
<cfargument name="myacct" type="string" required="yes" hint="Biz Org to get ">
<cfset var arrCases = ArrayNew(1)>
<cfquery datasource="ClarifySMST" name="get_cases">
select objid, x_object_id, x_site_id, x_site_name
from SA.TABLE_X_PORTAL_OBJECT
Where x_bus_org_objid = <cfqueryparam cfsqltype="cf_sql_integer" value="#myacct#">
</cfquery>
<!--- Calculate the Start Position for the loop query.
So, if you are on 1st page and want to display 4 rows per page, for first page you start at: (1-1)*4+1 = 1.
If you go to page 2, you start at (2-)1*4+1 = 5 --->
<cfset start = ((arguments.page-1)*arguments.rows)+1>
<!--- Calculate the end row for the query. So on the first page you go from row 1 to row 4. --->
<cfset end = (start-1) + arguments.rows>
<!--- When building the array --->
<cfset i = 1>
<cfloop query="get_cases" startrow="#start#" endrow="#end#">
<!--- Array that will be passed back needed by jqGrid JSON implementation --->
<cfset arrCases[i] = [#objid#,#x_object_id#,#x_site_id#,#x_site_name#]>
<cfset i = i + 1>
</cfloop>
<!--- Calculate the Total Number of Pages for your records. --->
<cfset totalPages = Ceiling(get_cases.recordcount/arguments.rows)>
<!--- The JSON return.
Total - Total Number of Pages we will have calculated above
Page - Current page user is on
Records - Total number of records
rows = our data
--->
<cfset stcCases = {total=#totalPages#,page=#Arguments.page#,records=#get_cases.recordcount#,rows=arrCases}>
<cfreturn stcCases>
<!--- <cfreturn get_cases> --->
</cffunction>
Firebug error is that the variable is not declared.
How do I do this?
Thanks, Jim
09:42

Moderators
30/10/2007

Hello,
First - it is a good idea to start with documentation.
Hint use setGridParam method and postData array to do that.
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.
Most Users Ever Online: 715
Currently Online:
31 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