This content has been marked as final. Show 5 replies
I don't know what exactly you mean by 'different editable properties' but I have dealt with this probelm recently on some of the dataGrids at work; we have some extremely large classes containing 20+ properties, and a dataGrid will only have, for example, 3 columns.
The best solution I have come up with is to create a second class with placeholder variables for each column, and then assign the appropriate properties to teh placeholder variables. In this way, you end up with 6+ rows representing one class.
This also requires some additional bookkeeping on the programmer's part; one would think that setting up an 'itemEditEnd' event to dump the text back to the source variable would do the trick, but that drops the last character. My solution was to set a text editor up to dump every keystroke into a storage variable, and then dump the storage variable back to the appropriate element in the original class when finished editing a cell.
It's a bit involved, and a lot of bookkeeping, but that's the only method I know of to place different properties inside the same column of a DataGrid.
different editable properties, what I mean by this
basically each item in the dataprovider(assigned to the datagrid) has a variable called user rank. If the user rank was greater than 4 for example, let the user edit the text for that specific row and corresponding column.
Then you should be able to do something like the attached example.
Basically, you check to see if the object that you clicked on has a rank <4; if it does, then you preventDefault, which prevents the cell from being edited.
You might be able to check dataGrid.selectedItem.rank, rather than dataProvider.getItemAt(event.RowIndex) as well.
What is dispatching the event you refer to and what type of DataGridEvent would it be?
The event is dispatched whenever you try and edit the dataGrid, and the event type is DataGridEvent. It is dispatched by the dataGrid in the attached example.