Forum


17:23

16/07/2008

I've seen a few other postings with the same "jQuery(modwin).jqDrag is not a function" error - however I cannot find a documented solution!
Here's my source code ...
$(document).ready(function(){
$("#grid").jqGrid({
url:'grid_param_redirect.jsp?baseUrl=https://david.nfis.org/wrt&gdasUrl=https%3A%2F%2Fncr.cfsnet.nfis.org%2Fgdas%2Fgdas%3FService%3DGDAS%26Request%3DGetData%26Version%3D0.9.1%26FrameworkDomain%3Dcfsnet.nfis.org%26FrameworkVersion%3D1%26FrameworkName%3DFOBIG_COSEWIC_data%26DatasetDomain%3Dcfsnet.nfis.org%26DatasetName%3Dfobig%26Attribute%3Dtaxomic_group%2Cforest_association%2Cspecies_name_e%2Cscientific_name%2Csituation1999%2Csituation2004%2Csituation2005%2Csituation2006%2Csituation2007%2Csituation2008%2Clast_cosewic_reassessment%2Cthreats%2Cpopulation_trend%2Con_schedule1%2Cdistribution%2Chabitat%2Cecozone%2Ccomment%2Cid&templateUrl=https://david.nfis.org/seedlist/grid_data.jsp&cache=true',
datatype: 'xml',
colNames:['Geolinkage Field','taxomic_group','forest_association','species_name_e','scientific_name','situation1999','situation2004','situation2005','situation2006','situation2007','situation2008','last_cosewic_reassessment','threats','population_trend','on_schedule1','distribution','habitat','ecozone','comment','id'],
colModel :[
{name: 'geolinkage_field', index: 'geolinkage_field', width: 120, sortable: true},
{name: 'taxomic_group', index: 'taxomic_group', width: 120, sortable: true},
{name: 'forest_association', index: 'forest_association', width: 120, sortable: true},
{name: 'species_name_e', index: 'species_name_e', width: 120, sortable: true},
{name: 'scientific_name', index: 'scientific_name', width: 120, sortable: true},
{name: 'situation1999', index: 'situation1999', width: 120, sortable: true},
{name: 'situation2004', index: 'situation2004', width: 120, sortable: true},
{name: 'situation2005', index: 'situation2005', width: 120, sortable: true},
{name: 'situation2006', index: 'situation2006', width: 120, sortable: true},
{name: 'situation2007', index: 'situation2007', width: 120, sortable: true},
{name: 'situation2008', index: 'situation2008', width: 120, sortable: true},
{name: 'last_cosewic_reassessment', index: 'last_cosewic_reassessment', width: 120, sortable: true},
{name: 'threats', index: 'threats', width: 120, sortable: true},
{name: 'population_trend', index: 'population_trend', width: 120, sortable: true},
{name: 'on_schedule1', index: 'on_schedule1', width: 120, sortable: true},
{name: 'distribution', index: 'distribution', width: 120, sortable: true},
{name: 'habitat', index: 'habitat', width: 120, sortable: true},
{name: 'ecozone', index: 'ecozone', width: 120, sortable: true},
{name: 'comment', index: 'comment', width: 120, sortable: true},
{name: 'id', index: 'id', width: 120, sortable: true}],
pager: jQuery('#pager'),
rowNum: 25,
rowList:[25,50,100],
viewrecords: true,
imgpath: 'scripts/themes/green/images',
height: 400,
shrinkToFit: false,
width: 800,
caption: 'Forest Biodiversity Information Gateway',
multiselect: true,
pager: 'pager'
}).navGrid('#pager', {
refresh: true,
edit: true,
add: true,
del: false,
search: true
});
$("#search").click(function() {
$("#grid").searchGrid();
});
});
</script>
</head>
<body>
<table id="grid" class="scroll" cellpadding="0" cellspacing="0"></table>
<div id="pager" class="scroll" style="text-align: center;"></div>
<p id="search">Search</p>
</body>
Suggestions? Thanks in advance ...
03:38

Moderators
30/10/2007

Do you have included in the head section the
jqModal.js and jqDnR.js plugins ?
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.
11:59

16/07/2008

Yup ... they are both included. The following four scripts are included:
<script src="scripts/jquery.jqGrid.js" type="text/javascript"></script>
<script src="scripts/js/jquery.jqModal.js" type="text/javascript"></script>
<script src="scripts/js/jquery.jqDnR.js" type="text/javascript"></script>
As you can see, I moved them to a parent directory called "scripts", but I updated the "jQuery.jqGrid.js" file so that "pathtojsfiles = 'scripts/js/';" - as in documentation. Could this be causing a problem?
12:11

Moderators
30/10/2007

Since there is a maybe problem with a loader, could you please
load the modules one by one.
Thank you
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.
18:11

16/07/2008

Even when I manually add all the scripts (as below) rather than using the loader - I get the same error. I also tried moving around script to different loactiosn, but the error still occurs ...
<script src="scripts/js/min/grid.base-min.js" type="text/javascript"></script>
<script src="scripts/js/min/grid.formedit-min.js" type="text/javascript"></script>
<script src="scripts/js/min/grid.inlinedit-min.js" type="text/javascript"></script>
<script src="scripts/js/min/grid.subgrid-min.js" type="text/javascript"></script>
<script src="scripts/js/min/grid.custom-min.js" type="text/javascript"></script>
<script src="scripts/js/min/grid.postext-min.js" type="text/javascript"></script>
<script src="scripts/js/jquery.jqModal.js" type="text/javascript"></script>
<script src="scripts/js/jquery.jqDnR.js" type="text/javascript"></script>
The problem only occurs when I add the:
refresh: true,
edit: true,
add: true,
del: false,
search: true
});
Everything in the grid (styles, sorting, selection, etc.) work just fine.
Any other ideas?
02:40

Moderators
30/10/2007

What about jqModal.css?
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.
11:21

16/07/2008

Yup, the stylesheets are being correctly referenced:
<link rel="stylesheet" type="text/css" media="screen" href="scripts/themes/jqModal.css" />
Using Firefox 3.0, everything in the grid is working properly with no JavaScript errors and only CSS warnings (for IE-specific tags). Only when I add the "navgrid" do I get errors. This is perplexing ....
11:32

Moderators
30/10/2007

Not sure if this is a problem, but you have set the pager two
times with two diffrent way. Remove the one and try in IE.
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.
11:42

Moderators
30/10/2007

I mean in the grid configuration - you have
...jqGrid({
....
pager: jQuery("#pager"),
....
pager : 'pager'
})
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.
05:42

22/08/2008

i saw the various posts , since i had the same problem.
in the include file
var minver = false;
remember that the filenames are
jqDnR.js , and jqModal.js
not
grid.jqModal.js , grid.jqDnR.js
Hope this helps someone.
amazing grid, Thanks
i have also created a C# class as a helper for my application
Code is given below
using System;
using System.Text;
using System.Collections;
using System.Data;
using System.Data.SqlClient;
namespace myapplication
{
/// <summary>
/// Description of Class1.
/// </summary>
public class jqGrid
{
/* Variables to store the grid rendering values*/
ArrayList cols = new ArrayList();
jqGriddef vgrid;
string pageno ;
DataSet ods ;
string keycol;
lib olib = new lib();
ArrayList actions = new ArrayList();
string imgpath = "'/css/themes/green/images'";
public jqGrid()
{
imgpath = "'" + olib.getwebconfig("apppath","") + "/css/themes/green/images'";
}
public bool addcoldef(jqColdef vdef)
{
// add the columns here
cols.Add(vdef);
return true;
}
public bool addcoldef(ArrayList vdef)
{
cols = vdef;
return true;
}
public bool addactiondef(ArrayList vdef)
{
actions = vdef;
return true;
}
public bool addgriddef(jqGriddef vdef )
{
vgrid = vdef;
return true;
}
public string getgrid()
{
// generate the grid created and return the string
StringBuilder sb = new StringBuilder();
sb.AppendFormat("jQuery(\\"{0}\\").jqGrid(",vgrid.gridelement);
sb.Append("{\\n");
sb.AppendFormat("url:{0},",vgrid.url);
sb.AppendFormat("datatype: \\"{0}\\",",vgrid.datatype);
sb.AppendLine("colNames:[");
sb.AppendLine(getcellcaptions());
sb.AppendLine("],");
sb.AppendLine("colModel:[");
// loop here for columns
sb.AppendLine(getcolmodel());
// end of columns
sb.AppendLine("],");
sb.AppendFormat("pager: jQuery('{0}'),",vgrid.pagerelement);
sb.AppendFormat("rowNum:{0},",vgrid.pageLength);
sb.AppendFormat("rowList:[{0}],",vgrid.pagelengthoptions);
sb.AppendFormat("imgpath:{0} ,",imgpath);
sb.AppendFormat("sortname: '{0}',",vgrid.initialsort);
sb.AppendFormat("height: '{0}',","auto");
sb.AppendLine("viewrecords: true,");
sb.AppendLine("sortorder: \\"desc\\",");
// last option note no comma
sb.AppendFormat("caption: \\"{0}\\"",vgrid.caption);
sb.AppendLine("})");
sb.AppendFormat(".navGrid('{0}',",vgrid.pagerelement);
sb.AppendLine("{refresh: true, edit: false, add: false, del: false, search: true});");
return sb.ToString();
}
private string getcellcaptions()
{
string cellcaptions = "";
bool firstcol = true;
foreach(jqColdef ocol in cols)
{
if(firstcol){
cellcaptions += "'" + ocol.caption + "'";
firstcol = false;
}else{
cellcaptions += ",'" + ocol.caption + "'";
}
}
return cellcaptions;
}
private string getcellfields()
{
string cellfields = "";
bool firstcol = true;
foreach(jqColdef ocol in cols)
{
if(firstcol){
cellfields += "'" + ocol.name + "'";
firstcol = false;
}else{
cellfields += ",'" + ocol.name + "'";
}
}
return cellfields;
}
private string getcolmodel()
{
StringBuilder colmodel = new StringBuilder();
bool firstcol = true;
foreach(jqColdef ocol in cols)
{
if(firstcol){
colmodel.Append("{");
colmodel.AppendFormat("name:'{0}',index:'{0}',width:{1},align:'{2}',sortable:{3}\\n",
ocol.name,ocol.width,ocol.align,ocol.sortable.ToString().ToLower());
colmodel.Append("}");
firstcol = false;
}else{
colmodel.Append(",{");
colmodel.AppendFormat("name:'{0}',index:'{0}',width:{1},align:'{2}',sortable:{3}\\n",
ocol.name,ocol.width,ocol.align,ocol.sortable.ToString().ToLower());
colmodel.Append("}");
}
}
return colmodel.ToString();
}
public string getjqdata()
{
// return the JSON string
int rowcount = gettotrowcount();
int pagecount = (rowcount/vgrid.pageLength) + 1;
StringBuilder sb = new StringBuilder();
sb.Append("{");
sb.AppendFormat("\\"page\\":\\"{0}\\",",pageno);
sb.AppendFormat("\\"total\\":\\"{0}\\",",pagecount);
sb.AppendFormat("\\"records\\":\\"{0}\\",",rowcount);
sb.Append("\\"rows\\":[");
getrows(sb);
// end rows
sb.Append("]}");
return sb.ToString();
}
private string getrows(StringBuilder osb)
{
// get the rows in JSON format
DataTable odt = null;
if(ods != null)
{
if(ods.Tables.Count > 0 )
{
odt = ods.Tables[0];
}
}
if (odt ==null)
{
return "";
}
bool firstrow = true;
foreach(DataRow odr in odt.Rows)
{
// begin row
/*If the Action array is > 0 then we need to add the actions to the grid
* add actions in the first column
* use the id to identify the item , no ajax in edit
* need to add the column model + col captions
* */
if(firstrow)
{
osb.Append("{");
firstrow = false;
}else{
osb.Append(",{");
}
osb.AppendFormat("\\"id\\":\\"{0}\\",",odr[keycol]);
osb.AppendFormat("\\"cell\\":[");
bool firstcol = true;
foreach(jqColdef ocol in cols)
{
if(firstcol)
{
osb.AppendFormat(ocol.format,odr[ocol.name],odr[keycol]);
firstcol = false;
}else{
osb.AppendFormat("," + ocol.format,odr[ocol.name],odr[keycol]);
}
}
osb.Append("]");
// end row
osb.Append("}");
}
return osb.ToString();
}
public bool setjqdata(string vpageno ,string vkeycol, DataSet vds )
{
pageno = vpageno;
ods = vds;
keycol = vkeycol;
return true;
}
public int gettotrowcount()
{
DataRow odr = olib.getfirstrow(ods);
if(odr != null)
{
return olib.getdatavalueint("totrows",odr);
}else{
return 0;
}
}
}
public struct jqColdef
{
public string name;
public string caption;
public string index;
public string width;
public string align;
public bool sortable;
public string type ;
public string format ;
public bool searchable;
// assume id = 0 , name = 1
public jqColdef(string vcaption, string vname , string vindex, string vwidth , string valign , bool bsortable)
{
name = vname;
index = vindex;
width = vwidth;
align = valign;
sortable = bsortable;
caption = vcaption;
type = "default";
format = "\\"{0}\\"";
searchable = true;
}
public jqColdef(string vcaption, string vname , string vindex, string vwidth , string valign , bool bsortable, string vtype, string vformat)
{
name = vname;
index = vindex;
width = vwidth;
align = valign;
sortable = bsortable;
caption = vcaption;
type = vtype;
searchable = true;
switch(type)
{
case "editlink":
format = "\\"<a href='edit.aspx?id={1}'>Edit</a>\\"";
width="50";
break;
case "addlink":
format = "\\"<a href='add.aspx'>Add</a>\\"";
width="50";
break;
case "deletelink":
format = "\\"<a href='delete.aspx?id={1}'>Delete</a>\\"";
width="50";
break;
case "eadlink":
format = "\\"<a href='edit.aspx?id={1}'>Edit</a> ";
format += "<a href='add.aspx'>Add</a> ";
format += "<a href='delete.aspx?id={1}'>Delete</a>\\"";
width="150";
break;
case "edlink":
format = "\\"<a href='edit.aspx?id={1}'>Edit</a> ";
format += "<a href='delete.aspx?id={1}'>Delete</a>\\"";
width="100";
break;
default:
format = vformat;
break;
}
}
}
public struct jqGriddef{
public string gridelement;
public string url;
public string datatype;
public string caption;
public int pageLength;
public string pagelengthoptions;
public string pagerelement;
public string initialsort;
}
}
Hope this helps.
13:34

16/07/2008

I finally found the solution here!
Most Users Ever Online: 715
Currently Online:
82 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