Hi Team
Here is the situation..I have a webdata grid with server side row selection changed event configured
OnRowSelectionChanged="dgLocGroups_RowSelectionChanged"
It is calling the method on any row selection change:
protected void dgLocGroups_RowSelectionChanged(object sender, SelectedRowEventArgs e)
I also have a button that is adding a new row to grid via javascript
function AddRow() {
var grid = $find('<%= dgkeywords="" clientid="">');
var editing = grid.get_behaviors().get_editingCore();
var rowAdding = editing.get_behaviors().get_rowAdding();
rowAdding._commitRow();
}
The row gets added well but when clicking on the cell to enter into edit mode post back is happening due to rowselection event .
Below is the code snippet of the behavior:
<Behaviors>
<ig:Selection Enabled="true" RowSelectType="Single" CellClickAction="Row">
<AutoPostBackFlags RowSelectionChanged="true" />
</ig:Selection>
<ig:EditingCore BatchUpdating="true">
<ig:RowAdding Enabled="true" EditModeActions-MouseClick="None"></ig:RowAdding>
<ig:CellEditing>
<EditModeActions MouseClick="Double" />
</ig:CellEditing>
</Behaviors>
</ig:EditingCore>
I have changed the EditModeActions of Cellediting to ‘Single’ but of no use.
Please help.
Varun
Hello Varun,
Thank you for contacting us.
This is expected behavior, when new row is added into the Grid and you select it, RowSelectionChanged event should be fired. When you start to enter a cell from the newly added row, this is considered as row changing, because previously the row was not selected, and then RowSelectionChanged event is fired.
Could you please let me know what you are trying to achieve in order to suggest you the best approach.
Looking forward to hearing from you.
Thanks for the explanation..
Requirement is that:
On row select of the grid, server side event is added that is doing some business process and displaying output to a textbox.
We also have add new button clicking of which is adding a new blank record to grid. As you mentioned, selecting that new record for data entry is also firing the row selection changed..
What I need that row selection post back need to be prevented when someone enters to new row cell edit mode.. Many be any cell edit enter client side to stop row selection post back?
Hello,
In that case you can handle RowSelectionChanging client event and to check if the row that you are trying to select is newly added, and if it is, to cancel the it.
Code snippet:
function RowSelectionChanging(sender, eventArgs) { var row = eventArgs.getNewSelectedRows().getRow(0); if ($(row.get_element()).is('[class*="AddingRow"]')) { eventArgs.set_cancel(true); } }
I am glad that you find my reply helpful.