11-17-2009 04:12 PM
11-18-2009 10:51 AM
You raise an interesting point. But after having thought about it for a while, I think the current behavior is correct, for the following reasons:
a) In your case, all the cells are indicators, but it's possible to make only individual cells be indicators. As such, the policy for sorting (if it took into account the individual indicator-state of each cell) would have to be to allow non-indicator cells to be moved, but not allow moving indicator cells. And if you're sorting multiple columns, that would require all the cells from each column that are in the same row as the indicator cell to also be locked in place. This would make for a confusing and undesirable user experience, as some rows might sort correctly while others don't.
b) the purpose of making a cell an indicator is to not allow the end user to change its value interactively. And you bring up a good point by arguing that if you make, say, cell (5,2) an indicator, but the control then allows you to swap cell (5,2) with cell (5,5) then, in a sense, the value of cell (5,2) has changed. But this is somewhat dependent on your perspective. For example, imagine that you have a table with user records, and you have something like this:
Row 1: <last name 1> <first name 1> <date of birth 1>
Row 2: <last name 2> <first name 2> <date of birth 2>
Now imagine that, for some reason, you want to disallow users from altering the second user's date of birth, so you make that cell an indicator. Now, if someone ends up swapping the two rows (for example, because they might want to sort their records alphabetically, by last name) you could view that as the cell's value changing. But in this case, that's not relevant. What matters is that that person's data was not changed.
I realize that this scenario is but one example, and it would be quite easy to come up with an example in which swapping cells really does present a problem. But as long as there are scenarios in which swapping is okay, that's still an argument against the control enforcing an outright prohibition against swapping indicator cells. Ultimately, it's up to the developer to decide what makes sense in his or her case, and then hide or show that menu item based on that decision. As you ended up doing.
Luis
11-19-2009 08:46 AM
11-19-2009 12:19 PM
You're absolutely right. The example I gave is too simplistic and it would indeed require some additional programmer gymnastics in order to behave correctly. I had considered that the programmer would probably have to check the right-click event and hide the Sort item whenever the selection was not suitable. But I hadn't considered that the end user could then still configure the sort, in the dialog that comes up, such that it would end up not making any sense.
So yes, in some cases, the programmer has no choice but to disable that menu item. If sorting is still desirable, it's always possible for the programmer to add a new item to the menu and then implement sorting it by calling the SortTableCells function, which is the programmatic way of sorting a range of cells.
Luis