Set prop of element an datagrid rows

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
doobox
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 284
Joined: Tue May 24, 2011 11:47 pm

Set prop of element an datagrid rows

Post by doobox » Wed Jul 13, 2011 8:58 am

Hi there,

I hit a brick wall with this.
I have a datagrid form, with a button(deleteButton) on the row template that it initially set to in-visible in the row template.

Now i have two test buttons on the card outside of the datagrid... "showdelete", "hidedelete"

Code: Select all

on mouseUp
set the visible of button "showdelete" to true
end mouseUp

Code: Select all

on mouseUp
set the visible of button "showdelete" to false
end mouseUp
This apparently on the face of it only shows or hides the button in the first row.
How to i ensure all rows are targeted from an external button..?
Kind Regards
Gary

https://www.doobox.co.uk

doobox
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 284
Joined: Tue May 24, 2011 11:47 pm

Re: Set prop of element an datagrid rows

Post by doobox » Wed Jul 13, 2011 9:11 am

Got it...!

Amazing.. Spent a couple of hours messing with this and as soon as a wrote here lights started to come on :-)

Code: Select all

put the dgProps["Row Template"] of group "DataGrid 1" into theRowTemplate
   set the visible of button "ButtonDelete" of theRowTemplate to false
   dispatch "ResetList" to group "DataGrid 1" of card "main"
Kind Regards
Gary

https://www.doobox.co.uk

Klaus
Posts: 14194
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Re: Set prop of element an datagrid rows

Post by Klaus » Wed Jul 13, 2011 4:33 pm

Hi Gary,

well, the DATAGRID is in fact a highly complex beast! :D
Glad you managed it!


Best

Klaus

doobox
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 284
Joined: Tue May 24, 2011 11:47 pm

Re: Set prop of element an datagrid rows

Post by doobox » Wed Jul 13, 2011 5:03 pm

Tell me about it :-)
I'm nearly done with the datagrid setup in this app. Just one little niggle.

I have an option to delete rows. By clicking a button in the title bar a delete button becomes visible on each row.
Click the button and it deletes the row and refreshes the datagrid.

The one issue is that if you try and delete the last row the grid does not refresh.
The data is in fact gone. I tested that by refreshing the grid from another button(that removes the last row)
So my question is: what is it about the grid that makes my code behave differently if there is only one row remaining..?

The button to show the delete buttons:

Code: Select all

on touchEnd pId
   mobGUIUntouch the long id of me
   
   if field "label" of me is "Done" then
       put "Edit" into field "label" of group "ButtonEdit"
   put the dgProps["Row Template"] of group "DataGrid 1" into theRowTemplate
   set the visible of button "ButtonDelete" of theRowTemplate to false
   dispatch "ResetList" to group "DataGrid 1" of card "main"
   else
      put "Done" into field "label" of me
      put the dgProps["Row Template"] of group "DataGrid 1" into theRowTemplate
      set the visible of button "ButtonDelete" of theRowTemplate to true
      dispatch "ResetList" to group "DataGrid 1" of card "main"
   end if
end touchEnd
then the code in the delete button of each row:

Code: Select all

on mouseUp pBtnNum
   put the dgHilitedLines of group "DataGrid 1" into theLine
   dispatch deleteLIne to group "DataGrid 1" with theLine
end mouseUp
this seems to refresh the grid after the line is deleted perfectly well unless its the last line..?
If i add this to the end of that mouse up handler it breaks it:

Code: Select all

dispatch "ResetList" to group "DataGrid 1" of card "main"
Yet my gut tells me thats exactly what it needs after removing the data from the last row.
Kind Regards
Gary

https://www.doobox.co.uk

Post Reply