Hi,
I have 2 columns in a WebDataGrid. It has AutoPostback setup on rowselectionchange. One of the columns is a checkbox. Is there any way to disable the postback on clicking the checkbox? Below is my sample code.
<ig:WebDataGrid ID="wdg1" runat="server" Height="350px" Width="400px" AutoGenerateColumns="false" OnRowSelectionChanged="wdg1_RowSelectionChanged"> <Columns> <ig:UnboundCheckBoxField Key="Select"></ig:UnboundCheckBoxField> <ig:BoundDataField DataFieldName="BrandName" Key="BrandName"></ig:BoundDataField> <ig:BoundDataField DataFieldName="BrandId" Key="BrandId" Hidden="true"></ig:BoundDataField> </Columns> <Behaviors> <ig:Selection CellClickAction="Row" RowSelectType="Single"> <AutoPostBackFlags RowSelectionChanged="true" /> </ig:Selection> <ig:EditingCore> <Behaviors> <ig:CellEditing> <ColumnSettings> <ig:EditingColumnSetting ColumnKey="Select" ReadOnly="false" /> </ColumnSettings> </ig:CellEditing> </Behaviors> </ig:EditingCore> </Behaviors> </ig:WebDataGrid>
Hello Vivek,
You can put logic in the RowSelectionChanging client side event to achieve the required. This logic needs to cancel the default behavior, if the RowSelectionChanging is triggered by selecting the checkbox, and then manually remove/add rows to the selected rows collection:
This is how you attach to the event:
This is the event handler:
function WebDataGrid1_Selection_RowSelectionChanging(sender, eventArgs){
// following if statement determines if a checkbox has been clicked, because it is not a real checkbox, but an IMG element if (event.target.tagName === "IMG") { eventArgs.set_cancel(true); var newRow = eventArgs.getNewSelectedRows().getRow(0); var lastRow = eventArgs.getCurrentSelectedRows().getRow(0); // deselect last row sender.get_behaviors().get_selection().get_selectedRows().remove(lastRow); // Select row sender.get_behaviors().get_selection().get_selectedRows().add(newRow); }}
Please let me know if you have further questions, I will be glad to help.