User Option to Select all rows in a datagrid

smadduri
smadduri Member
edited May 31, 2012 in Documentum #1

Hi ,

I have datagrid with paging enabled having multiple rows .

my requirement is to select all the rows inside the data grid with an option provided '"Select ALL"  which should select all rows inside datagrid.

Can any help me how this can be achieved .

Regards

Srini

Tagged:

Comments

  • VadimYakovlev
    VadimYakovlev Member
    edited May 31, 2012 #2

    You can include this as your first header column

    <dmf:datagridTh resizable="false" nowrap="true" width="30">                                        <input type="checkbox"  id="clearSelection" name="clearSelection" onclick="selectDeselect(this)" ></dmf:datagridTh>

    and this as the first column

    <dmf:datagridRowTd  scope="row" nowrap="true"  width="30" align="center">                                                  <dmf:checkbox id="boxSelection" name="boxSelection" /> <dmf:label id="labelObjectId" name="labelObjectId" datafield="r_object_id" visible="false"/>                                        </dmf:datagridRowTd>

    and handle the selection/deselection via javascript

    function selectDeselect(box) {          var elementsArray = document.getElementsByName('boxSelection');          for (i = 0; i < elementsArray.length; i++)           {                     elementsArray[i].checked = box.checked ;          }}

    But perhaps there's a better, more elegant, more WDK way of doing this.