views:

209

answers:

1

hello friends. I have a gridview data and this gridview have subgrid too. in the first column of the grid view having + symbol so that i can expand the grid to see subgrid.. but now problem is I need to have a button in the bottom of the grid to expand all the gridview subgrid at a time..

Thanks

A: 

Give a class to every button that is used to expand row and then use jQuery trigger:

<table>
  <tr>
     <td><button class='expand-row-button'>+</button></td><td>other things</td>
  </tr>
  <tr>
     <td><button class='expand-row-button'>+</button></td><td>other things</td>
  </tr>
  <tr>
     <td><button class='expand-row-button'>+</button></td><td>other things</td>
  </tr>
</table>

<button onclick="$('.expand-row-button').trigger('click');">Expand all rows</button> 

** EDIT **

Because you are using jqGrid, you should look at expandSubgridRow method. This method is used to expand row with specified id. You can iterate through rows in your view and generate code to expand every row.

LukLed
Thanks for your replay..I need to place the button under the Grid and I need to expand all the rows at one button click event...please is the above code do the same thing?thanks
kumar
what is this Expand-row-button? from where we need to give this?
kumar
If every button used to expand row has class `expand-row-button` and you use jQuery then that should work. This code creates button, which when is clicked, triggers clicking of all expand buttons.
LukLed
http://www.secondpersonplural.ca/jqgriddocs/_2eb0giikm.htmsame i have the gridview like this.. same way i need to keep the Button in the bottom of the grid to expand all the + sing at a time.. thanks
kumar
@tncbbthositg: Maybe this post will help: http://www.trirand.com/blog/?page_id=393/treegrid/expand-all-and-collapse-all-functionality-in-tree-grid/
LukLed
Please can you look in to this sameple codehttp://www.secondpersonplural.ca/jqgriddocs/_2eb0giikm.htmsame I have like this.. I dont have any button in the grid.. directly i have the grid data with first colum + i need to expand all the + to show subgrid data on one button clickthanks
kumar
pleae can you tell me how to iterate throw my row to expand all the rows?thanks
kumar
<button onclick="$('.expand-row-button').trigger('click');">Expand all rows</button>this code is not working nothing is happening on button click event..thanks
kumar