Diese Seite mit anderen teilen ...

Informationen zum Thema:
WinDev Forum
Beiträge im Thema:
Erster Beitrag:
vor 7 Monaten, 1 Woche
Letzter Beitrag:
vor 7 Monaten
Beteiligte Autoren:
Curtis, DarrenF, Allard

[WD20] Table with Breaks - Recall Expand/Collapsed State [SOLVED]

Startbeitrag von Curtis am 09.01.2017 16:11

I have a table with breaks. I want to be able to reload the table data and then recall the expanded/collapsed state of each break. So if the user has breaks 1,3, and 7 expanded, when the table gets reloaded I would expand those 3 breaks. Any ideas? The only code event for the break is the initial displaying of rows.

I would also like to be able to double click the break header to expand/collapse, but I haven't been able to find a way. It's really annoying to have to find the 16px icon to click when the whole break row is there to double click.



Re: [WD20] Table with Breaks - Recall Expand/Collapsed State


TableExpand() and tablecollaps() are functions you can use


von Allard - am 09.01.2017 19:02

Re: [WD20] Table with Breaks - Recall Expand/Collapsed State


I would save the ID of the expanded breaks and use TableExpand() using the IDs to find the correct breaks. The problem is there is no event associated with clicking the expand/collapse icon, so I have no way to know which breaks are expanded.

von Curtis - am 09.01.2017 20:34

Re: [WD20] Table with Breaks - Recall Expand/Collapsed State

Hey Curtis,

Yeah, it's possible... in fact I took up your challenge...

I have a window with a table control and a break header.

So, I first added a button control and made it transparent using the Style tab. I did this before placing it on the break header just to make it easier to work with.

You can have the user single click or double click - I decided on the single click event to make it easier for the user.

Next, search for "..colapsed" in the online help; there's even some example code that does exactly what you are looking for... so tweak it for your purposes and add this code to your chosen button click event.

If you haven't done already, change the size of the button and put the button on the break header and that's it... hit 'Go' to test it; the header alternatively expands and contracts.

Edit: ..and failed the challenge - only the first header expands and contracts - how to get the button to appear on all break headers?


von DarrenF - am 09.01.2017 21:43

Re: [WD20] Table with Breaks - Recall Expand/Collapsed State

Hi Curtis,

Okay, here's how to do it... no coding required:

1) Find the required height and width of the break header you're trying to "fill".
2) Design a graphic (it's a 2-state graphic), so it's basically double the width.
3) In your favourite graphics package, design your (very wide) 2-state button, with the + followed by the -.
4) Double-click the Table control and go to the Style tab.
5) In the "Element:" drop-down, select "Break, border in creation".
6) Select the graphic you've just lovingly created (above).
7) Validate your selection.
8) Hit "Go" to test it.

On my window the Expanded version looks like:

[attachment 2269 ImgMinus.PNG]

...and the Collapsed:

[attachment 2270 ImgPlus.PNG]

Admittedly, my minus sign needs aligning a bit, but hey... :xcool: ...and you can click anywhere on the break header - happy days! :cheers:

von DarrenF - am 10.01.2017 00:34

Re: [WD20] Table with Breaks - Recall Expand/Collapsed State


Just noticed your other requirement:

I want to be able to reload the table data and then recall the expanded/collapsed state of each break.

I think the following works when the window reloads - I don't use it so I'm not sure if it also works when the Table control is reloaded?

von DarrenF - am 10.01.2017 10:29

Re: [WD20] Table with Breaks - Recall Expand/Collapsed State

Thanks for all of your help. I'll try the graphic option as soon as I have a chance.

As far as the AAF, I had no idea about it, but it doesn't seem to work with a table by programming that gets reloaded.

EDIT: It works and it scales/anchors perfectly. Thanks! Now if I could just figure out how to save expanded/collapsed states.

von Curtis - am 10.01.2017 17:51

Re: [WD20] Table with Breaks - Recall Expand/Collapsed State

I figured out how to save/load the state of the breaks. It's actually similar to your solution for clicking anywhere on the break, and overrides it.

1) Create a blank image for the expand/collapse icons.
2) Set the image in the style>break,border in creation.
3) Create an image control on top of the break header.
4) Make it the whole width of the header with 100% width anchoring.
5) Now when the image is clicked you can expand/collapse the correct break, set the correct expand/collapse images, and you can also save whatever data you want to an array.
6) Use the array data to collapse/expand the correct breaks when reloading the table.

Below is the code I use in the Click event of the image. I have an array that holds all collapsed items. If I expand the break I delete the item from the array. If I collapse the break I add the item to the array.

nBreakRow is int = TableBreakSubscript(BRK_ItemHeader,TableBreakSubscript(BRK_ItemHeader))

IF TABLE_Inventory.BRK_ItemHeader..Collapsed THEN

// Expand break.
TABLE_Inventory[nBreakRow].IMG_Expanded = TABLE_BREAK_EXPAND_ICON


// Collapse break.

gaaCollapsedInventory[COL_Item] = True

von Curtis - am 19.01.2017 16:28
Zur Information:
MySnip.de hat keinen Einfluss auf die Inhalte der Beiträge. Bitte kontaktieren Sie den Administrator des Forums bei Problemen oder Löschforderungen über die Kontaktseite.
Falls die Kontaktaufnahme mit dem Administrator des Forums fehlschlägt, kontaktieren Sie uns bitte über die in unserem Impressum angegebenen Daten.