I am causing a post back of the webdatagrid (with new control parameters from my object data source) ... from the client side.
I need the first row of the new grid to be the selected row.
Using the following code, I am able to programmatically remove the selected row(s) from the previous webdatagrid result set and make the first row of my current set the selected row.
var selectedRows = grid.get_behaviors().get_selection().get_selectedRows(); for (var i = selectedRows.get_length() - 1; i >= 0; i--) { selectedRows.remove(selectedRows.getItem(i)); } selectedRows.add(grid.get_rows().get_row(0));
Everything works fine, except the arrow in the navigation column of the webdatagrid ... for the previously selected row ... is still displaying.
So now, I have 2 arrows (if the previous row was other than the first) ... one for the currently selected (and highlighted row) and one for the previously selected row.
When I do a "selectedRows.remove()", I need a way to programatically remove the persisted pointer from the grid display as well.
Hi pgrad,
Do you have the Activation behavior on, too? And row selectors? The pointers are in the row selector? If you have an active cell, its row selector will have an image (pointer, too). You could try clearing the active cell or moving it to your new selected row.
regards,David Young
Yes I do. Below are the relevant configuration statements:
this.WebDataGrid1.Behaviors.CreateBehavior<Activation>();Selection gridSelection = this.WebDataGrid1.Behaviors.CreateBehavior<Selection>();gridSelection.CellClickAction = CellClickAction.Row;RowSelectors gridRowSelectors2 = this.WebDataGrid1.Behaviors.CreateBehavior<RowSelectors>();this.WebDataGrid1.Behaviors.Selection.RowSelectType = SelectType.Single;this.WebDataGrid1.Behaviors.Selection.CellSelectType = SelectType.None;
It would be very helpful if you could you provide actual code examples of how to access the row selector pointers, or how to clear the active cell ... both in code-behind and javascript.
Thanks.
Hello pgrad,When Activation is turned on and there is an active cell the row selector will be marked as active and the solution is every time a postback is made it is necessary to clear the active cells.
A simple way to clear the active cells is setting the collection containing them to null - this.WebDataGrid1.Behaviors.Activation.ActiveCell = null;
If activation is turned off clearing the selected rows is enough. I have created a sample for you using the Northwind database showing how to handle row selectors. Code is with activation enabled
1. Run the sample.
2. Select a row
3. Click the button
4. Observe the results
Now you can observe the results after commenting the this.WebDataGrid1.Behaviors.Activation.ActiveCell = null; in Button1_Click eventhandler;
If you comment this.WebDataGrid1.Behaviors.CreateBehavior<Activation>(); in Page_Load function now you can see the results with and without commenting this.WebDataGrid1.Behaviors.Selection.SelectedRows.Clear(); in Button1_Click.Please let me know if you need further assistance with this matter.
This worked for me.
this.WebDataGrid1.Behaviors.Activation.ActiveCell = null
I was having an issue where the selected row persisted across changing the data shown in the grid. And it was a real issue when only one row was returned as there was no way to deselect the row and then select it so it would act like you just selected on it (clicking in a cell worked, but not the row selector).
Cliff