I 'm using the webdatagrid v11.1 and need to do a validation. I have created a datatable and bind it to a webdatagrid wich generate all the columns needed.
But some cells are left blank, so I want to make a validation using this event: SelectionClientEvents-CellSelectionChanging to find if the new cell has content, if it has no content, cancel the selection, else the selection will continue.
This is the aspx code for webdatgrid
<ig:WebDataGrid ID="wdgCalendario" runat="server" Height="350px" Width="100%">
<Behaviors>
<ig:Activation Enabled="true" ActivationClientEvents-ActiveCellChanging="OnActiveCellChanging" />
<ig:Selection RowSelectType="None" CellClickAction="Cell" Enabled="true" CellSelectType="Single" SelectionClientEvents-CellSelectionChanging="OnCellChanging" SelectionClientEvents-CellSelectionChanged="OnCellChanged"></ig:Selection>
<ig:RowSelectors></ig:RowSelectors>
</Behaviors>
</ig:WebDataGrid>
And I hva no idea how this validation can be done via javascript.
Hi jcvegan,
Thank you for posting in our forum.
I would suggest that you handle the CellSelectionChanged client side event of the grid. You could use code, similar to the following to check if the selected cell is empty and deselect it, if it is:
function WebDataGrid1_Selection_CellSelectionChanged(sender, eventArgs) {
//gets the selected cell
var selectedCell = eventArgs.getSelectedCells().getItem(0);
//gets the value of the cell
var cellValue = selectedCell.get_value();
//if the value is null remove the selected cell from the selected cells collection
if (cellValue == null) {
sender.get_behaviors().get_selection().get_selectedCells().remove(selectedCell);
}
Please let me know if this helps.
Works like a charm! thanks!
Hello jcvegan,
I'm glad I could help.
If you have any other questions, please do not hesitate to ask.
How can I assign the active cell as a selected cell?
You could try to do this using the following code:
var activeCell = sender.get_behaviors().get_activation().get_activeCell();
sender.get_behaviors().get_selection().get_selectedCells().add(activeCell);
If you have any further questions please feel free to contact me.