The table columnCount

when delete the column from ArrayItem via model.removeArrayItem(coldefs, deleteCol);
the table.columnCount do not change. so my code ref the columnCount so don’t work correctly. always out of bound.

Especially when column width is be set.

It is little complicated , so I made this exsample,

when we resize the column then delete, then the column is remains.
Screen Recording 2021-08-10 at 2.18.50 AM

It looks like the RowColumnDefinitions for the columns are remaining in the “Table” Panel. That’s why when you delete a column the following columns aren’t being “shifted left”.

I think you have at least two choices.
(1) You could modify all of the following columns so that they have the correct new column number, and copy the other settable properties that you care about
(2) You could make the deleted column have zero width

I tried the two option it don’t work. still “remaining
in the same sample if you just add one column and delete it, it column number is clean, but still “remaining
Screen Recording 2021-08-10 at 4.39.27 AM

There is still a column resizing handle there, even though it’s no longer needed. And referring to a RowColumnDefinition will automatically create it if needed.

Yes, it is, I already unselect it and reselect back. but it still remaining!

I think in model view system, model data is already deleted, then the view should also to delete the shown data right?

in here I bet the column count not change back it is 4.

And delete row have same problem also.

Yes, the RowColumnDefinitions are automatically created when referenced and remain until someone calls Panel.removeColumnDefinition. That method isn’t called just because an element was removed that referred to a no-longer-used column. So then the Panel.columnCount remains the same, even though visually the number has decreased.

The reason is that the set of RowColumnDefinitions is sparse – it’s perfectly reasonable to have only a single RowColumnDefinition, say for column #17, without there existing any other RowColumnDefinitions for columns in that “Table” Panel.

Though maybe it could be smarter about decreasing the columnCount when the “last” one is removed.

Kindly thank you quick response. so, Panel.removeRowColumnDefinition seems I can’t call it from my code. I really need this dynamically add/remove column feature, because have this feature than we can call is the real Table

OK, in v2.1.48 we will fix the behavior of Panel.removeRowDefinition and Panel.removeColumnDefinition to decrease the corresponding Panel.rowCount and Panel.columnCount when removing the highest index RowColumnDefinition.

That should cause the ColumnResizingTool’s Adornment to be updated to show the “correct” number of resize handles after you have called Panel.removeColumnDefinition.

Walter, thank you so much. :)

By the way, I am right now, when I was delete the column, reassigning the column number.

for example, there are 0,1,2,3,4,5 columns, then I delete column number 3 , it will became, 0,1,2,4,5
then I reassign the column number to 0,1,2,3,4 then commit it to diagram model.
dynamically add/remove columns, the column number is the key.

thank you release v2.1.48,
I try to use this version to test it, but it seems still remains

image

when i should call Panel.removeColumnDefinition ? after delete the column from model data? or before?

Take a look at the update Add Remove Columns sample: Add or Remove Columns

I added a call to Panel.removeColumnDefinition to the function that removes column 3.

yes still remains ,

I copy the code to jsfiddle, but seems still remains

to reproduce this, add the column and delete it, then deselect the node, and select it, and carefully drag the resize line then got the same result.