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
Grid with subGrid problem
19/03/2009
09:13
Avatar
Jim P
Member
Members
Forum Posts: 102
Member Since:
29/01/2009
sp_UserOfflineSmall Offline

Tony,

I have a grid with a subgrid as a grid.  The top level grid has two columns, which have links controled by onCellSelect event.  When I open the subgrid and resize any column of the subgrid it fires the onCellSelect event on the top grid.    This condition happens in IE and FF browsers.

Here's my code:

<script>
// ********************************************************************************************
//  Single Combined List Option
// ********************************************************************************************
 $(document).ready(function()
  {
   $("#slist").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','Priority','Site ID','Site Name','Status','Reported 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:"text", width: 70},    
        {name:'x_priority',index:'x_priority',  align:"center", sorttype:"text", width: 60},
     {name:'x_site_id',index:'x_site_id',  align:"center",sorttype:"text", width: 60},
     {name:'x_site_name',index:'x_site_name',  align:"left",sorttype:"text"},
     {name:'x_status',index:'x_status',  align:"center", sorttype:"text", width: 60},
     {name:'x_title',index:'x_title',  align:"left", sorttype:"text"},
     {name:'x_creation_dt',index:'x_creation_dt',  align:"center", sorttype:"date"},
     {name:'objid',index:'objid', hidden:true, search:false},
     {name:'x_object_objid',index:'x_object_objid', hidden:true, search:false},
     {name:'x_parent_objid',index:'x_parent_objid', hidden:true, search:false},
     {name:'x_parent_type',index:'x_parent_type', hidden:true, search:false}
    ],
    afterInsertRow : function(rowid,rowdata,rowelem) {
    $("#"+rowid+" td:eq(1)").css("color", "005D8C");  // change font col 1 to note it's a link
    $("#"+rowid+" td:eq(3)").css("color", "00748C");  // change font col 3 to note it's a link
    if (rowdata.x_parent_type == "children" && rowdata.x_parent_objid == 0)
     {
        $("#"+rowid+" td:eq(0)").empty().unbind("click");
         }  
     },
    width:900,
    onCellSelect: function(rowid,iCol,cellcontent){
       if (iCol == 1)
       {
      //alert (rowid,iCol,cellcontent);
     ColdFusion.Window.show("casedetails");
     //window.location.href = "casedetails.cfm?cid="+cellcontent;
       }
     if (iCol == 3)
       {
        ColdFusion.Window.show("sitedetails");
       //window.location.href = "sitedetails.cfm?sid="+cellcontent;
        }
    },
    cellEdit: false,
    //height:200,
    //shrinktofit: true,
    pager: $('#pager'), //The div we have specified, tells jqGrid where to put the pager
    rowNum: <cfoutput>#session.maxlines#</cfoutput>, //Number of records we want to show per page
    //rowList:[10,25,50,100], //Row List, to allow user to select how many rows they want to see per page
    sortorder: "", //Default sort order - desc
    sortname: "x_priority", //Default sort column
    viewrecords: true, //Shows the nice message on the pager
    imgpath: 'themes/basic/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
    mtype:'GET',
    recordtext:' Total Records', //On the demo you will notice "7 Total Records" - The Total Reocrds text comes from here
    pgtext:' page of a total 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.
    //Things to do when grid is finished loading
                loadComplete:function(){
      // Hide the site name column per user settings
      var hidesite = <cfoutput>#session.SiteDD#</cfoutput>;
      if(hidesite == 1){
      $("#slist").hideCol("x_site_name");
      }
           //We get the Userdata for the grid.
                        var recorddata = $("#slist").getUserData();
                        //If the msg type is error, we do some CSS and change text color to red, otherwise its blue
                        if(recorddata.TYPE == "Error"){
                            $("#t_slist").css("color","red")
                        }else{
                            $("#t_slist").css("color","blue")
                        }
                        //Display the message in the toolbar
                        $("#t_slist").html(recorddata.MSG)
      },
    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("#slist").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&q=2&id="+row_id+"&x_object_id="+rowdata.x_object_id,
              datatype: "json",
                 colNames: ['ID','Create D/T','Category','Priority','Status','Part Number','Part Desc','Description',''],
              colModel: [
              {name:"x_object_id",index:"x_object_id",key:true, align: "center", width:70
     , formatter:'showlink', formatoptions:{baseLinkUrl: 'prdetails.cfm',showAction:''}
     },
              {name:"x_creation_dt",index:"x_creation_dt", align:"left",datefmt:"Y-m-d", sorttype:"date", width:70},
              {name:"x_category",index:"x_category",align:"left", width:70, hidden:false},
                 {name:"x_priority",index:"x_priority",align:"left", width:70},          
              {name:"x_current_state",index:"x_current_state",align:"left", width:70},
     {name:"x_part_number",index:"x_part_number",align:"left", width:70},
     {name:"x_part_description",index:"x_part_description",align:"left"},
     {name:"x_title",index:"x_title",align:"left"},
     {name:'mytyp', hidden:true}
                        ],
       height: 'auto',
       width:900,
       imgpath: 'themes/basic/images', //Image path for prev/next etc images
       cellEdit: false,
       // change which fields to show
       afterInsertRow : function(rowid,rowdata,rowelem) {
       if (rowdata.mytyp == "PR")
     {
       $("#"+subgrid_table_id).hideCol("x_priority");
       $("#"+subgrid_table_id).setLabel("x_object_id","PR No.");
        }
     else
     {
     $("#"+subgrid_table_id).hideCol("x_part_number");
     $("#"+subgrid_table_id).hideCol("x_part_description");
     $("#"+subgrid_table_id).setLabel("x_object_id","SubCase No.");
     } 
     },
      rowNum: 10,
             //imgpath: 'themes/green/images', //Image path for prev/next etc images,
             sortname: 'num',
         //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"}
     },
             sortorder: "asc"
           })
       },
  

    //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",
     userdata: "USERDATA",
     cell: "",
     id: "0",
     subgrid: {root: "ROWS", repeatitems: true, cell: "",id:"0"}
     }
    }
   );   
    $.extend($.jgrid.search,
    {caption:"Filter",
       Find:'Search',
       width:'400',
       checkInput:true,
       top:200,
       left:400,
       sopt: ['eq','ne','lt','le','gt','ge','bw','cn']     
      });
     
    $("#slist").navGrid("#pager",{edit:false,add:false,del:false,searchtext:"Filter"}).navButtonAdd('#pager',{
          caption:"To PDF", buttonimg:"images/pdf.png", onClickButton: function(){document.location.href='ExportTo.cfm?typ=p&met=DumpCases&myacct=<cfoutput>#session.bizorg_objid#</cfoutput>';}, position:"last", title:'Export to PDF' }).navButtonAdd('#pager',{
          caption:"To Excel", buttonimg:"images/icon-xls.png", onClickButton: function(){document.location.href='ExportTo.cfm?typ=e&met=DumpCases&myacct=<cfoutput>#session.bizorg_objid#</cfoutput>';}, position:"last", title:'Export to Excel' })
    ;

</script>

21/03/2009
10:26
Avatar
tony
Sofia, Bulgaria
Moderator
Members

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

Hello,

Thanks. It seems to be a bug.

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.

25/03/2009
08:58
Avatar
Jim P
Member
Members
Forum Posts: 102
Member Since:
29/01/2009
sp_UserOfflineSmall Offline

Tony,

I changed my subgrid column model to resizable:false, which will not allow me to change the column width.   That's good.

If I hold the left mouse button down and move it back and forth over the edge of the column, like I'm trying to resize the column, and then release the button, it fires the fires the onCellSelect of the top grid.  If you just move the mouse once or twice and release it doesn't fire.  But, if you move the mouse a lot the window fires and I get  [413 Header Length too Large]

I tested this in IE6 & FF.

Jim

Forum Timezone: Europe/Sofia

Most Users Ever Online: 715

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