Is it possible to select multiple rows in a WebDataGrid without holding CTRL, SHIFT, or dragging? Basically, I would like the selected rows to remain "sticky", kind of like a checkbox functionality, except with the row selection element (ie. click an unselect row to select, click a selected row to unselect - but without affecting the rest of the selected rows in the process).
I've tried tricking the event object in the browser into thinking the CTRL key is pressed (via JS), but I don't think it's possible.
Hi Koojo,
This should be possible with a little code on the client. You will want to turn on selection behavior, but set CellSelectType="None" and RowSelectType="None". This will mean the actual behavior will do no selecting from the UI. Now, you will want to handle the grid's click or mouse down event. In that handler, you will select the clicked row if it is unselected or unselect it if it were already selected.
function wdg_Click(webDataGrid, evntArgs) { var ControlClicked = evntArgs.get_type(); var row = null; var selectedRows = webDataGrid.get_behaviors().get_selection().get_selectedRows(); if (ControlClicked == 'row') { row = evntArgs.get_item(); webDataGrid.get_behaviors().get_selection().get_selectedRows().clear(); } else if (ControlClicked == 'cell') { row = evntArgs.get_item().get_row(); } if (row != null) { if (selectedRows.indexOf(row) > -1) webDataGrid.get_behaviors().get_selection().get_selectedRows().remove(row); else webDataGrid.get_behaviors().get_selection().get_selectedRows().add(row); } }
I hope this gives you the behavior that you want.
regards,
David Young
I'm using Infragistics 9.2, and the parameters in my event handler look different. Below is my code, I get an error on "grid.get_behaviors()" (Object doesn't support this property or method"):
on code behind I set clientside event handler:
this.DisplayLayout.ClientSideEvents.CellClickHandler = "QueryResults_CellClickHandler";
BLOCKED SCRIPT
function QueryResults_CellClickHandler(gridId, cellId, button) {
var cell = igtbl_getCellById(cellId);
var row = cell.Row;
var grid = igtbl_getGridById(gridId);
var selectedRows = grid.get_bahaviors().get_selection().get_selectedRows();
if (row != null) {
if (selectedRows.indexOf(row) > -1)
grid.get_behaviors().get_selection().get_selectedRows().remove(row);
else
grid.get_behaviors().get_selection().get_selectedRows().add(row);
}
Hi,
The code I gave works for the WebDataGrid. Your event handler indicates you are using the UltraWebGrid. The forum for that control is located here.
regards,David Young
I'm trying to use your example code but I'm having no luck. Can you tell me where I'm going wrong. Using v11.1
Grid:
<ig:WebDataGrid ID="grdProfessions" runat="server" DataSourceID="dataProfessions" Height="225px" StyleSetName="PPRHealthcare" Width="210px"
AutoGenerateColumns="False" DataKeyFields="strProfession" >
<Columns>
<ig:BoundDataField DataFieldName="strProfession" Key="strProfession">
<Header Text="Profession" />
</ig:BoundDataField>
<ig:BoundDataField DataFieldName="intWebSortOrder" Hidden="True" Key="intWebSortOrder">
<Header Text="intWebSortOrder" />
</Columns>
<ClientEvents MouseDown="grdProfessions_Grid_MouseDown" />
<Behaviors>
<ig:Selection CellSelectType="None" RowSelectType="None">
</ig:Selection>
<ig:Activation>
</ig:Activation>
</Behaviors>
</ig:WebDataGrid>