I have a datagrid supporting inline editing. One of the columns is a dropdown. When the user actions to add a new record, I initialise the dropdown so that it holds a list of products where the key is an ID and the displayed value the product name. I also insert an 'Add Product' option, giving it an ID of -1.
If the user selects the 'Add Product' row, I open a dialog box where they can add a new product. I return its ID and set the datagrid column to its ID value.
This all works perfectly apart from the custom validator I have set on the dropdown column, which ensures an ID value greater than zero is selected. As I select the 'Add Product' option, the validator triggers the error message, but it does not disappear when I return from the dialog screen, even though I update the dropdown box selected value. I have to manually change the selected value and then change it back again to remove the error message.
Doesn't seem to. By way of testing this, I am displaying the ID value from the dropdown as the error message, and it does contain the new product's ID when I return from the dialog screen, but although it's value has not changed, it is not re-triggering the validation. Can I force a re-validation of the datagrid as a whole, or even a particular column, in some way?
Think I've found a way to do this. When the dropdown's change event fires, I check if they've chosen the 'Add New Product' option. If so, then I set a boolean to false. In the Edit Context for the Dropdown, I wrap the custom validator within an if check on this boolean field. I turn this field on again only after I've returned from the dialog screen and set the dropdown to the new, valid value.
It's not 100% perfect because, when the 'Add New Product' value is selected, the error message does still show, but I can live with that as long as it disappears when I return with the new value.