Strange wrapping behaviour of lines in data grid

Got a LiveCode personal license? Are you a beginner, hobbyist or educator that's new to LiveCode? This forum is the place to go for help getting started. Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller

Post Reply
keram
Posts: 340
Joined: Fri Nov 08, 2013 4:22 am

Strange wrapping behaviour of lines in data grid

Post by keram » Sun Feb 16, 2014 5:16 pm

Hi,

I have a data grid that displays text lines that can be toggled as wrapped lines and non-wrapped lines.
I'm using this script:

Code: Select all

on mouseUp  --toggle dontWrap t/f
   lock screen
   put not the dgProp["fixed row height"] of grp "DataGrid 1" into tNewSetting
   set the dgProp["fixed row height"] of grp "DataGrid 1" to tNewSetting  --toggle t/f fixed line height
   set the dontWrap of fld "Label" of grp "Row Template 0001" of grp "dgList" of grp "dgListMask" of grp "DataGrid 1" to tNewSetting
   
   set the dgVScroll of grp "DataGrid 1" to "0"  --top
   send "RefreshList" to grp "DataGrid 1"  --update changes
end mouseUp
The lines show wrapping on but only some. Then move the scrollbar down and up and the lines that were wrapping are now not wrapping, while others are.
When testing (see the attached stack) click first on the button "Insert Data". Then test the wrapping.

Also another strange behavior is that when you click on the button 'Insert Data' while the lines are in Wrapping on view, then they all collapse to non-wrapped view but not fully, then click on 'Wrap o/x' button and they will contract sort of little more and then again after clicking on Wrap button they will expand.

Is all this due to wrong code or simply a bug in LC?
(using LC Community 6.5.2 on Win 7 Home Premium, 64bit, Intel i3, with 4 GB Ram)

keram
Attachments
DG Form strange wrapping.zip
(18.29 KiB) Downloaded 196 times
Using the latest stable version of LC Community 6.7.x on Win 7 Home Premium, 64bit

Zryip TheSlug
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 163
Joined: Tue Jan 26, 2010 10:15 pm
Contact:

Re: Strange wrapping behaviour of lines in data grid

Post by Zryip TheSlug » Sun Feb 16, 2014 11:59 pm

Hi Keram,

This is not a LiveCode bug.

When you are changing the dontWrap property of the fld "Label" of grp "Row Template 0001", you are changing only one field control in the datagrid. When we are scrolling the datagrid, this field is pushed regularly on the top of the datagrid, that's the reason you have the feeling some rows are affected and others not.

To have the script working, you have to set the dontWrap property of the field "Label" inside the row template:

Code: Select all

put the dgProp["row template"] of grp "DataGrid 1" into tRowTemplateRef
set the dontWrap of fld "Label" of tRowTemplateRef to tNewSetting
As we have changed the template, we have the need to refresh the datagrid by sending to it the "ResetList" message:

Code: Select all

send "ResetList" to grp "DataGrid 1"
Have a look to this lesson:

http://lessons.runrev.com/s/lessons/m/d ... ugh-script


The final script to use in the wrap button:

Code: Select all

on mouseUp  --toggle dontWrap t/f
   local tNewSetting, tRowTemplateRef
   
   put not the dgProp["fixed row height"] of grp "DataGrid 1" into tNewSetting
   set the dgProp["fixed row height"] of grp "DataGrid 1" to tNewSetting  --toggle t/f fixed line height
   put the dgProp["row template"] of grp "DataGrid 1" into tRowTemplateRef
   set the dontWrap of fld "Label" of tRowTemplateRef to tNewSetting
   
   set the dgVScroll of grp "DataGrid 1" to 0 --top
   send "ResetList" to grp "DataGrid 1" --update changes
end mouseUp

Best,
TheSlug
http://www.aslugontheroad.com - Tutorials, demo stacks and plugins for LiveCode
Data Grid Helper - An intuitive interface for building LiveCode's Data Grids
Excel Library- Extends the LiveCode language for controlling MS Excel

keram
Posts: 340
Joined: Fri Nov 08, 2013 4:22 am

Re: Strange wrapping behaviour of lines in data grid

Post by keram » Mon Feb 17, 2014 3:34 am

Thanks a lot! :D
Using the latest stable version of LC Community 6.7.x on Win 7 Home Premium, 64bit

Post Reply