views:

24

answers:

1

I am not familiar with dojo. I have this application I am using that has a dojo data grid.

    <table jsid="grid" id="grid" dojoType="dojox.grid.DataGrid" store="store"
    clientSort="true" style="height: 400px;"  rowsPerPage="10"
    postrender="setTableCount(store,'count');"
    >
<thead>
<tr>
    <th field="enabled" width="24px" styles='text-align: center;'
        celltype="dojox.grid.cells.Bool" formatter="formatterEnabled"
        dojoType="dijit.form.CheckBox"><img src='../common/images/check-16.png' title='Enabled'/></th>
    <th field="number" width="100px" >Number</th>

    <th field="name" width="100px" >Name</th>
    <th field="extension" width="100px" >Extension</th>
    <th field="type" width="100px" >Type</th>
    <th field="deleted" width="20px"
        formatter="formatterZombieSkill">
        <img src='../common/images/blocks-delete-16.png' title='Marked for deletion'/></th>
</tr>
</thead>

The generated table is large, and I want to highlight 10 rows that are spread out in the grid. For example, if the extension column is sorted, and it runs from 1..10000, I want to highlight rows 1, 32, 435, and 980. I can do this with the mouse click while holding down the ctrl button, but when I have 40 values to select, this becomes tedious.

I don't have server-side access to the code, so I just want to simply use my browser's script engine.

I'd like to just type in some quick javascript like:

javascript: var x = [1, 2, 3]; for(i in x) { /*SELECT/HIGHLIGHT/SIMULATE-CLICK THE ROW WHERE THE VALUE IN THE COLUMN NAMED EXTENSION = x[i]*/}

Can one of you dojo gurus help me out with the missing select statement?

+1  A: 

I'm not a dojo guru, but this may do what you need, if you are trying to just programatically select rows... I think DataGrid contains an instance of dojox.grid.Selection.

http://api.dojotoolkit.org/jsdoc/1.3.2/dojox.grid.Selection

The Selection dijit has a method called setSelected, which I believe takes an index and a boolean for selected/not selected. So I think you could do:

dijit.byId("grid").selection.setSelected(i, true);

I haven't tested it, but I think that will do the Select / Highlight that you need. Give it a try and let me know if it works.

JasonStoltz
I installed firebug in Firefox and realized it was not possible to do this in just the UI, because the grid's contents change as I move the scrollbar thumb. I'll have to dig into it when I have some idle time.
ericp