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_TopicIcon
Help changing from subgrid to grid as subgrid
09/02/2009
14:51
Avatar
Jim P
Member
Members
Forum Posts: 102
Member Since:
29/01/2009
sp_UserOfflineSmall Offline

I got my subgrid working.  Now I want to change the subgrid to a Grid as s Subgrid.

I get the following error:

<!--- <cfset session.myacct = "268440464"> --->
<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>
 $(document).ready(function()
  {
   $("#list").jqGrid(
   {
    url:'Users.cfc?method=GetAllCases&myacct=<cfoutput>#session.bizorg_objid#</cfoutput>', //CFC that will return the users
    datatype: 'json', //We specify that the datatype we will be using will be JSON
    colNames:['Case Number','Priority','Site ID','Site Name','Status','Problem','Created','','','',''], //Column Names
    //The Column Model to define the data. Note you can make columns non sortable, specify width, alignment, etc.
    colModel :[
        {name:'x_object_id',index:'x_object_id', align:"center", sorttype:"string", width:80},
     {name:'x_priority',index:'x_priority',  align:"center", sorttype:"string", width:80},
     {name:'x_site_id',index:'x_site_id',  align:"center",sorttype:"string", width:90},
     {name:'x_site_name',index:'x_site_name',  align:"center",sorttype:"string", width:150},
     {name:'x_status',index:'x_status',  align:"center", sorttype:"string", width:100},
     {name:'x_title',index:'x_title',  align:"left", sorttype:"string", width:300},
     {name:'x_creation_dt',index:'x_creation_dt',  align:"center", sorttype:"string", width:200},
     {name:'objid',index:'objid', hidden:true},
     {name:'x_object_objid',index:'x_object_objid', hidden:true},
     {name:'x_parent_objid',index:'x_parent_objid', hidden:true},
     {name:'x_parent_type',index:'x_parent_type', hidden:true}
    ],
    afterInsertRow : function(rowid,rowdata,rowelem) {
    if (rowdata.x_parent_type == "children" && rowdata.x_parent_objid == 0)
     {
        $("#"+rowid+" td:eq(0)").empty().unbind("click");
         }  
     },
    width:1000,
    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: "x_object_id", //Default sort column
        //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
    postdata: "",  // my account
    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.
    subGrid: true, // make it a subgrid

// problem is in this code - if commented out it works fine

    subGridRowExpanded: function(subgrid_id, row_id) {
      // we pass two parameters
       // subgrid_id is a id of the div tag created within a table
       // the row_id is the id of the row
    // If we want to pass additional parameters to the url we can use
    // the method getRowData(row_id) - which returns associative array in type name-value
       // here we can easy construct the following
       var subgrid_table_id;
       subgrid_table_id = subgrid_id+"_t";
        jQuery("#"+subgrid_id).html("<table id='"+subgrid_table_id+"' class='scroll'></table>");
            jQuery("#"+subgrid_table_id).jqGrid({
           url:"Users.cfc?method=GetSubCases&q=2&id="+row_id,
            datatype: "xml",
            colNames: ['Subcase ID','Create D/T','Category','Priority','Statusl','Description'],
            colModel: [
              {name:"x_object_id",index:"x_object_id",width:80,key:true},
              {name:"x_creation_dt",index:"x_creation_dt",width:130},
              {name:"x_category",index:"x_category",width:80,align:"right"},
             {name:"x_priority",index:"x_priority",width:80,align:"right"},          
              {name:"x_status",index:"x_status",width:100,align:"right",sortable:false},
     {name:"x_title",index:"x_title",width:100,align:"right",sortable:false}
                         ],
     height: 100%,
              rowNum:20,
             imgpath: gridimgpath,
             sortname: 'num',
             sortorder: "asc"
        }   
  //  subGridUrl: 'Users.cfc?method=GetSubCases', //CFC that will return the users
  //  subGridModel: [{
  //     name: ['SubCase No','Priority','Creation Date','Problem'], //Column Names
  //     width: [100, 100, 175, 300],
  //     params: ['x_object_id']}
  //  ],

    //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",
     subgrid: {root: "ROWS", repeatitems: true, cell: "",id:"0"}
     }
    }
   );   
   
  }
 );  // end of document ready
 
 $("#t_list").css("color","red");
 //

 </script>

</head>

<body>

 <table id="list" class="scroll" cellpadding="0" cellspacing="0"></table>
 <div id="pager" class="scroll" style="text-align:center;"></div>
 <div id="mysearch"></div>
</body>
</html>

syntax error
 height: 100%,\\n
Here's my code.  Any help would be appreciated - Jim

10/02/2009
09:10
Avatar
Jim P
Member
Members
Forum Posts: 102
Member Since:
29/01/2009
sp_UserOfflineSmall Offline

OK, I solved the sytax problem:  Now my subgrid in a grid headings show up nut not the data.  Firebug shows valid json subgrid data being returned but it's not showing in the grid.  Do I need to change the json reader values?

Please help.  thanks - Jim

 <script>
 $(document).ready(function()
  {
   $("#list").jqGrid(
   {
    url:'Users.cfc?method=GetAllCases&myacct=<cfoutput>#session.bizorg_objid#</cfoutput>', //CFC that will return the users
    datatype: 'json', //We specify that the datatype we will be using will be JSON
    colNames:['Case Number','Priority','Site ID','Site Name','Status','Problem','Created','','','',''], //Column Names
    //The Column Model to define the data. Note you can make columns non sortable, specify width, alignment, etc.
    colModel :[
        {name:'x_object_id',index:'x_object_id', align:"center", sorttype:"string", width:80},
     {name:'x_priority',index:'x_priority',  align:"center", sorttype:"string", width:80},
     {name:'x_site_id',index:'x_site_id',  align:"center",sorttype:"string", width:90},
     {name:'x_site_name',index:'x_site_name',  align:"center",sorttype:"string", width:150},
     {name:'x_status',index:'x_status',  align:"center", sorttype:"string", width:100},
     {name:'x_title',index:'x_title',  align:"left", sorttype:"string", width:300},
     {name:'x_creation_dt',index:'x_creation_dt',  align:"center", sorttype:"string", width:200},
     {name:'objid',index:'objid', hidden:true},
     {name:'x_object_objid',index:'x_object_objid', hidden:true},
     {name:'x_parent_objid',index:'x_parent_objid', hidden:true},
     {name:'x_parent_type',index:'x_parent_type', hidden:true}
    ],
    afterInsertRow : function(rowid,rowdata,rowelem) {
    if (rowdata.x_parent_type == "children" && rowdata.x_parent_objid == 0)
     {
        $("#"+rowid+" td:eq(0)").empty().unbind("click");
         }  
     },
    width:1000,
    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: "x_object_id", //Default sort column
        //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
    postdata: "",  // my account
    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.
    subGrid: true, // make it a subgrid
          subGridRowExpanded: function(subgrid_id, row_id) {
      // we pass two parameters
       // subgrid_id is a id of the div tag created within a table
       // the row_id is the id of the row
    // If we want to pass additional parameters to the url we can use
    // the method getRowData(row_id) - which returns associative array in type name-value
       // here we can easy construct the following
         var subgrid_table_id;
      
       var rowdata = jQuery("#list").getRowData(row_id);

       subgrid_table_id = subgrid_id+"_t";
          jQuery("#"+subgrid_id).html("<table id='"+subgrid_table_id+"' class='scroll'></table>");
          jQuery("#"+subgrid_table_id).jqGrid({
            url:"Users.cfc?method=GetSubCases&x_object_id="+rowdata.x_object_id,
              datatype: "json",
                 colNames: ['Subcase ID','Create D/T','Category','Priority','Status','Description'],
              colModel: [
              {name:"x_object_id",index:"x_object_id",width:80,key:true},
              {name:"x_creation_dt",index:"x_creation_dt",width:130},
              {name:"x_category",index:"x_category",width:80,align:"right"},
                 {name:"x_priority",index:"x_priority",width:80,align:"right"},          
              {name:"x_status",index:"x_status",width:100,align:"right",sortable:false},
     {name:"x_title",index:"x_title",width:100,align:"right",sortable:false}
                        ],
       height: 100,
             rowNum:20,
             imgpath: 'themes/coffee/images', //Image path for prev/next etc images,
             sortname: 'num',
             sortorder: "asc"
           })
       },
  
  //  subGridUrl: 'Users.cfc?method=GetSubCases', //CFC that will return the users
  //  subGridModel: [{
  //     name: ['SubCase No','Priority','Creation Date','Problem'], //Column Names
  //     width: [100, 100, 175, 300],
  //     params: ['x_object_id']}
  //  ],

    //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",
     subgrid: {root: "ROWS", repeatitems: true, cell: "",id:"0"}
     }
    }
   );   
   
  }
 );  // end of document ready
 
 $("#t_list").css("color","red");
 //

 </script>

11/02/2009
00:21
Avatar
tony
Sofia, Bulgaria
Moderator
Members

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

Hello,

You should check what you return from server. When you move from subgrid to grid as subgrid you should synchronoze the jsonRedear of the subgrid. The subgrid properties of the main grid in this case does not have sense.

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.

11/02/2009
10:14
Avatar
Jim P
Member
Members
Forum Posts: 102
Member Since:
29/01/2009
sp_UserOfflineSmall Offline

Tony,

I solved my problem by added a second jsonReader into the deifinition of the subGrid.  I was following the example in the documentation (Oct 08)-page 87.

Perhaps you need to revise that example to show the jsonReader in that subGrid code block.

Thanks, Jim

Forum Timezone: Europe/Sofia

Most Users Ever Online: 715

Currently Online:
48 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