Page 1 of 1

Set prop of element an datagrid rows

Posted: Wed Jul 13, 2011 8:58 am
by doobox
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..?

Re: Set prop of element an datagrid rows

Posted: Wed Jul 13, 2011 9:11 am
by doobox
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"

Re: Set prop of element an datagrid rows

Posted: Wed Jul 13, 2011 4:33 pm
by Klaus
Hi Gary,

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


Best

Klaus

Re: Set prop of element an datagrid rows

Posted: Wed Jul 13, 2011 5:03 pm
by doobox
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.