LiveCode LessonsData GridLiveCode Data GridUseful Things To KnowWhat Sorts of Things Should I Not Do In Order To Avoid Needless Suffering?

What Sorts of Things Should I Not Do In Order To Avoid Needless Suffering?

There are some things that you could do that will cause you to scratch your head when things go wrong. Since knowing is half the battle we will share the issues we are aware of.

Don't call a handler that redraws the data grid from within a control in the data grid

This will generate an error since you are deleting a control that is currently executing code. This is a no-no and the Revolution engine will complain and stop executing. You can avoid calling a handler that refreshes the data grid from within a control by a) using send in time or b) placing the code in the data grid script itself.

Example A

## Script that is in the row behavior for a data grid.
send "DeleteIndex theIndex" to the dgControl of me in 0 seconds

Example B

## Script that deletes hilited index on mouseUp.
## Place in the data grid script.
on mouseUp pMouseBtnNum
local tIndex
   if pMouseBtnNum is 1 then
      put the dgHilitedIndex of me into tIndex
      DeleteIndex tIndex
   end if
end mouseUp

Don't try to draw a Data Grid on a card that Is not open

When a Data Grid renders it dynamically creates fields and accesses certain properties. Some of these properties can not be properly reported by the Revolution engine unless the field is on an open card.

Do not lock messages when accessing data grid properties.

If messages are locked when you try to access a data grid property (i.e. the dgProps["alternate row color"] of group "DataGrid") then the correct value will not be returned/set. When messages are locked getProp/setProp handlers are not triggered in Revolution and the data grid relies on these.

Do not password protect the Data Grid Templates Stack

The data grid copies the templates from the Data Grid Templates xxxx stack. If you password protect this stack then the data grid will be unable to copy the templates.

Don't Rename the "Data Grid Templates" Stack

If you rename this stack then all of your data grids with templates stored in the stack will stop working. Since the data grid can no longer locate the custom templates they will fail to draw properly.

Don't Try to Search When Data is Being Loaded From an External Source

Stop Editing the Template Group Before Drawing Your Data Grid

When you edit a group in Revolution the engine no longer knows that the group exists. If you try to draw a data grid while editing it's template group then the data grid will fail to draw.

1 Comments

Dave Mckay

I'd also recommend not copying a data grid - I had an app with 3 DGs that listed all entries in 3 different types of class so I made 1 and copied it twice.

Seemed to work fine at first but, as I edited the row template I noticed that they were linked, even though the DGs were distinct objects. In fact, selecting any of the 3 different DGs and clicking the Row Behavior button opened the same code.

So - don't copy DGs to save time, it'll cost you more trouble in the end!

Add your comment

This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.