I have a requirement to be able to specify specific types for grid cell values, such as integer, float, string. In addition, the user can specify a particular “mask” or other constraint value for the field.
For example, with “integer”, we wouldn’t allow a decimal number, and we may have a range constraint such as >0 or between 100 and 200.
For type “float”, we could have a range value
For type string, we could have a mask value which would be useful in formatting things like phone numbers, (###) ###-#### or social security numbers ###-##-####.
What would be the recommended approach for this? I’m assuming some kind of custom excells for this? Can you point to examples or specific docs on writing? If I have a custom excell, how does one pass in the configuration values in XML (for example, if I say how do I say that the mask field is “###-##-####”?
It can be done with custom eXcell. Please find tutorial here docs.dhtmlx.com/doku.php?id=dhtm … l_creation
But is it possible to pass parameters to it?
For example, if I have a custom excell of type integer but it has an additional constraint where a range of possible values can be specified (e.g., integer from 1 to 100), how would this additional constraint be passed in so the excell could validate it?
I tried another approach and that was to return the “constraint” data as user data, then on the client side use onEditCell to validate the data. The problem here is that when I return “false” it was not properly showing the “red line” but simply ignored the new_value and moves the cursor to the next line in the grid. I thought my onEditCell was intefering with the dataprocessor but I commented that out and had the same result.
Basically, I need a way that on a cell by cell basis, my servlet can return XML that allows the client side to validate the cell type and make sure that it conforms to the specified constraint. Some cells may be integer or float with a range, some may be strings with a mask (eg, ###-##-####), etc.
Please let me know your recommended approach. By the way I am using DataProcessor to manage inserts/deletes/changes to the grid.
You can try to use validation extension
docs.dhtmlx.com/doku.php?id=dhtm … validation
it allows to create custom validation rules
docs.dhtmlx.com/doku.php?id=dhtm … _extension
so you will be able to define a set of custom rules and provide in data xml only validation types for the cells.
The validation extension doesn’t seem to work properly with the dataprocessor…
My current approach is to use the onEditCell event in my grid. I can validate the value and return true/false. However, if I return false, the data is still sent to the server and it is not shown as invalid (red outline, etc.).
Note: I cannot use the dataprocessor’s setVerificator() because my table is heterogeneous in that some cells of the same column could have different verificators.
I cannot use dataprocessor’s onBeforeRowUpdate because it is for an entire row and I would not be able to show which cells are invalid.
All I want to be able to do is return false from my onEditCell and have the cell shown visibly as “invalid” (and prevent the data from flowing to the server)… please help!
I have solved this problem. Since I am using DataProcessor, I have to use the verificator framework… the other methods did not work correctly.
So, I basically added a listener on rowSelected…
grid.attachEvent(“onRowSelect”, function(id,ind) …
When the user selects a row,
- Clear any prior verificators for this grid
- Get the specification for each cell from userdata (e.g., Integer[0-100])
- Set the verificator for each column to a custom validation routine for that type
This allows the cells of the grid to have any type and have additional constraints and allows client side verification.