justinmind-logo
 
Upvote 1

Add row to data list does not expand panel

Answered Dan Cash 6 years ago

I have a data list in a dynamic panel. My hope was that as new rows are added to the data list, the panel would expand to accomadate the display of the new rows in the data list. Also, the content below the data list would be pushed down. This is not happening. Any suggestions on how I can make this work?

Replies (8)
photo
1

You can add two "On Data Change" events to the data list row, one that has an action of "Resize" that resizes the size of the dynamic panel and one that has an action of "Move" that moves the type based upon a change in size of the dynamic panel. You would determine the panel resize value and the type movement distance value based upon a count of the data master records.

The expression for your panel resize value is simply the number of rows in the data master (using the "Count" function with the data master) multiplied by the row height plus the height of the header.

For the type movement value, probably the easiest way would be to store the row count of the data master in a variable BEFORE the data change, then in your expression subtract that variable value from the row count of the data master, which would be AFTER the data change has occurred. This would give the row count change, which could be a positive or negative value, depending upon the change made to the data master. Multiplying this value by the row height gives you the offset the type should be moved with respect to its current position, therefore use "Offset" in the "Move" action settings.


Hope this makes sense and helps.

Cheers!

photo
1

Thanks for your response. That makes sense. However, I'm not sure on which object to tie the "On Change" event. The Data List doesn't allow events. Don't seem to be able to select a row. A cell doesn't have an On Change. The data element in a cell "[MyData.DataItem]" does have an On Change. When I use this object with the On Change events as you describe, nothing happens.

Question: Am I moving the dynamic panel below the data list? That is how I understood your instructions.

photo
1

I realized after I posted that my description of how to handle the movement of the type isn't possible because "Offset" isn't an choosable option since that dropdown setting needs to be "Calculated" in order to enter the expression that calculates the distance in pixels the text needs to be moved.

So, instead I put together a prototype that shows how it can be done in order for the panel resizing and text movement to work as you described. There are two versions, a barebones version and a version that has a dashboard that provides information on the different values that change as you add and delete records. Even though the extensions are .rar, they are not compressed. That's simply the extension this support forum accepts for file uploads. Just change the extensions from .rar to .vp.

Additional Detail (Justinmind Support Staff, please read):

One thing I noticed that's odd that perhaps the JIM support staff can address is that the number of data changes that occur in response to a single change to the data master (e.g. add one record) is equal to the number of rows in the data master, not just one for the single change that was executed. I'm not sure why this is. It seems like adding one record should be one data change.

This data change count oddity seems to create a strange behavior when creating the expression that determines the distance to move the type. If I create a "Set Value" event with an expression that calculates the distance value and then sets that value to a variable and then use that variable in the text "Move" action expression, the type moves exactly the distance it's supposed to. However, if I just use the same distance calculation expression directly in the text "Move" action without using a variable (which seems like the most efficient way to do it), it moves the type the amount it should be moved TIMES THE NUMBER OF ROWS IN THE DATA MASTER. So, when adding a record and going from two rows to three rows, instead of it moving the type the correct amount of 40px (40px being the correct amount for the attached prototype), it moves the type 120px (40px X 3 rows). When going from three rows to four rows, it moves the type 160px rather than just another 40px. This I feel is connected to the number of data changes that are registering for a single record addition, causing the "On Data Change" event to execute for every data change event registering. Seems odd behavior in that, if you want to use "On Data Change", you would assume (or at least I would) that an addition/deletion/modification of a single record would only trigger one data change event.

Cheers!

photo
1

Thanks! This looks like it will work. However, I can't seem to add a on data change event to my data list. How do I add that? I've tried clicking everywhere I can think of inside my data list and nothing is offering that event.

photo
1

You will see the actions associated with the "On Data Change" event in the prototype I provided on the element "sample_data_list_row".

photo
1

I see the actions in your example. I couldn't find the object that the actions were tied to. Looks like they are on the header row. I was able to find an on change trigger in the header for of my data list. Thanks

photo
1

In case it isn't clear in my comments and questions, this approach is working. Thanks very much to the eggroll for the assist!!

photo
1

Glad to hear it's working for you! To follow up, when you add a new data list to a screen, it should look like this (assuming you have already added fields and data to the data master you associate with the data list).

d97d9e95a46f451503427530d5276d33

The highlighted element "Current_row_1" is the element you are able to attach an "On Data Change" event to.

5ee8613c3ab0bb3728902ef90f956c4b

Leave a Comment
 
Attach a file