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
how do you toggle the sub grid indicators (+ - ) based on row content
03/02/2009
10:29
Avatar
Jim P
Member
Members
Forum Posts: 102
Member Since:
29/01/2009
sp_UserOfflineSmall Offline

Not all of the main grid rows will have a sub row.  This is indicated by one of the fields returned with the row.   In the documentation I see code to disable/enable a sub grid:  $("grid_id").hideCol("subgrid").

Can this be used with the postdate function to archieve the desired effect of not displaying (+ or -) when there isn't any sub row to display?

Do you have any examples of code to perform this?

TIA,  Jim

05/02/2009
01:26
Avatar
tony
Sofia, Bulgaria
Moderator
Members

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

Hello,

Humm - very interesting. Also as main directions - you can remove the image from the subgrid column and unbind the click (in this case the toggle) something like this: I suppose the subgrid column is the first and you have the rowid

$("#"+rowid+" td:eq(0)").empty().unbind("toggle")

Please let me known if this work.

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.

05/02/2009
08:39
Avatar
junwei
New Member
Members
Forum Posts: 1
Member Since:
05/02/2009
sp_UserOfflineSmall Offline

The above method does work however when click on the cell, the icon show up again. Is there any way to totally disable subgrid button for that particular row?

05/02/2009
08:57
Avatar
Jim P
Member
Members
Forum Posts: 102
Member Since:
29/01/2009
sp_UserOfflineSmall Offline

I'm a complete nubie to jqgrid.  Can you show me and example where to place that code.  I've been searching both the online documentation and the manual I downloaded on how to add the code.

TIA - Jim

05/02/2009
09:02
Avatar
tony
Sofia, Bulgaria
Moderator
Members

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

Sorry,

Try this:

$(”#”+rowid+” td:eq(0)”).empty().unbind(”click”)

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/02/2009
10:00
Avatar
Jim P
Member
Members
Forum Posts: 102
Member Since:
29/01/2009
sp_UserOfflineSmall Offline

Tony,

I'm completely lost here.  I don't see any examples on how to do this in the documentation.

If my query returns a field [gotsubs], how do I test that field as the grid is rendered.  Then if [gotsubs] is true, do this:

$(”#”+rowid+” td:eq(0)”).empty().unbind(”click”)

Jim

05/02/2009
15:28
Avatar
Jim P
Member
Members
Forum Posts: 102
Member Since:
29/01/2009
sp_UserOfflineSmall Offline

Anyone, 

I've been search your documentation and the web all day.  I can't find the syntax to use for the  afterInsertRow event.  This is what I've got:

    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_type',index:'x_parent_type', hidden:true}
    ],
    afterInsertRow: function(rowid,rowdata,rowelem){
       if (rowid && rowdata:x_parent_type:value !== "children"){
      $(”#”+rowid+” td:eq(0)”).empty().unbind(”click”));  1   
       }
     },

This of course doesn't work but I can't find an example any where.

The condition I'm testing for is:

 if the x_parent_type does not have a value of children

Remove the the + toggle from the row.

thanks again,  Jim

06/02/2009
03:05
Avatar
tony
Sofia, Bulgaria
Moderator
Members

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

Hello,

Could you please try only this to be a sure that all subgrids are empty:

afterInsertRow: function(rowid,rowdata,rowelem){
      $(”#”+rowid+” td:eq(0)”).empty().unbind(”click”));
 }

This will ensure that the code is working.

Also I'm not sure what you try to do with this

if (rowid && rowdata:x_parent_type:value !== “children”)

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/02/2009
07:42
Avatar
Jim P
Member
Members
Forum Posts: 102
Member Since:
29/01/2009
sp_UserOfflineSmall Offline

Tony,

In Firebug on FF I get this error on the code you ask me to run.


From running this code:

afterInsertRow: function(rowid,rowdata,rowelem){
      $(”#”+rowid+” td:eq(0)”).empty().unbind(”click”));
 },

The answer to your second question of what I was trying to do with this statement:

if (rowid && rowdata:x_parent_type:value !== “children”)

In my top grid query, NOT all rows will have a sub rows.  The x_parent_type column will have a value of "children" if there are sub rows.  If the the value of the x_parent_type is NOT Equal to "children" I need to disable the subgrid toggle.

Thanks, Jim

illegal character
 
 $(”#”+rowid+” td:eq(0)”).empty().unbind(”click”));},\\n
06/02/2009
07:44
Avatar
Jim P
Member
Members
Forum Posts: 102
Member Since:
29/01/2009
sp_UserOfflineSmall Offline

Jim P said:  The error statement got moved to the bottom of my last post.

Tony,

In Firebug on FF I get this error on the code you ask me to run.

illegal character
 
 $(”#”+rowid+” td:eq(0)”).empty().unbind(”click”));},\\n

From running this code:

afterInsertRow: function(rowid,rowdata,rowelem){
      $(”#”+rowid+” td:eq(0)”).empty().unbind(”click”));
 },

06/02/2009
08:24
Avatar
tony
Sofia, Bulgaria
Moderator
Members

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

Hello,

You should not copy paste the code from here, but understand what I try to expalin.

Here is a working example tested on my demo:

$("#mygrid").jqGrid({

...,

afterInsertRow : function(rowid,rowdata,rowelem) {

$("#"+rowid+" td:eq(0)").empty().unbind("click");

},

...

});

Hope this helps

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/02/2009
08:59
Avatar
Jim P
Member
Members
Forum Posts: 102
Member Since:
29/01/2009
sp_UserOfflineSmall Offline

Thanks Tony,

That worked!  The problem was the wrong ” - correct ".

The if statement still isn't working.

 afterInsertRow : function(rowid,rowdata,rowelem) {
     if (rowdata:x_parent_objid:value > 0 && rowdata:x_parent_type:value !== "children")
        $("#"+rowid+" td:eq(0)").empty().unbind("click");
     },

No errors in FB, just doesn't return anything. Blank screen.

Thanks again,  Jim

06/02/2009
09:11
Avatar
tony
Sofia, Bulgaria
Moderator
Members

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

Hello,

Maybe it is a good idea to learn how to get values from JS object. Sorry if this make you something wrong, but expression of type:

rowdata:x_parent_objid does not exists at all in JS - you should do something like this:

note the . and not :

if ( parseInt(rowdata.x_parent_objid) > 0 && rowdata.x_parent_type !== 'children') {

// do something here

}

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/02/2009
09:25
Avatar
Jim P
Member
Members
Forum Posts: 102
Member Since:
29/01/2009
sp_UserOfflineSmall Offline

Tony,

Thanks once again.  As you can tell I am just learning javascript.  I have no one I work with to ask questions.  I'm trying to learn it as I go.

You have been very helpful.

Thanks again,  Jim

06/02/2009
12:46
Avatar
Jim P
Member
Members
Forum Posts: 102
Member Since:
29/01/2009
sp_UserOfflineSmall Offline

For those that have been following this thread:

To toggle the subgrid indicator on/off based on field(s) in your main query.

$("#mygrid").jqGrid({

...,

    afterInsertRow : function(rowid,rowdata,rowelem) {
    if (rowdata.x_parent_type == "children" && rowdata.x_parent_objid == 0)
     {
        $("#"+rowid+" td:eq(0)").empty().unbind("click");
         }  
     },

...

});

In my instance my query returned two fields (hidden) that controled the toggle.

Have fun and Tony thanks again,  Jim

Forum Timezone: Europe/Sofia

Most Users Ever Online: 715

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