dispatch "DeleteLine" to group not working

LiveCode is the premier environment for creating multi-platform solutions for all major operating systems - Windows, Mac OS X, Linux, the Web, Server environments and Mobile platforms. Brand new to LiveCode? Welcome!

Moderators: heatherlaine, Klaus, FourthWorld, robinmiller, kevinmiller

Post Reply
yeldarb
Posts: 43
Joined: Thu Dec 14, 2017 5:39 pm

dispatch "DeleteLine" to group not working

Post by yeldarb » Thu Dec 28, 2017 8:45 pm

I have a datagrid object that gets populated with data correctly. Each row has a button to delete that record. After some processing I send the "DeleteLine" command:

Code: Select all

dispatch "deleteline" to group "recordsGrid" with whichRecLine
but nothing happens to the datagrid. What's odd is that if I send the exact same message from the message dialog the row gets deleted.

quailcreek
Posts: 717
Joined: Sun Feb 04, 2007 11:01 pm
Location: McKenna, WA

Re: dispatch "DeleteLine" to group not working

Post by quailcreek » Fri Dec 29, 2017 12:08 am

From within the datagrid things work a little differently.
Try this:

Code: Select all

dispatch "deleteLine" to the dgControl of the target with whichRecLine
Tom
MacBook Pro OS High Sierra 10.13.5

yeldarb
Posts: 43
Joined: Thu Dec 14, 2017 5:39 pm

Re: dispatch "DeleteLine" to group not working

Post by yeldarb » Fri Dec 29, 2017 3:01 pm

Thanks, but the command is being dispatched from the card script. I tried what you suggested and still no luck. I also tried re-filling the DG with the affected data (since I delete the pertinent line from the data and save it to a file) but that doesn't work either. The grid gets populated on openCard, and the data gets deleted, and if I leave the card and come back the deleted line is gone, but I can't get the grid to refresh at the time of deletion.

Here's my card script

Code: Select all

local allRecords

on openCard
   fillRecordsGrid
end openCard

on fillRecordsGrid
   put getTheRecords() into allRecords
   
   set the itemDelimiter to tab
   put 0 into counter
   repeat for each line thisLine in allRecords
      add 1 to counter
      put item 1 of thisLine into recordArray[counter]["profile"]
      put item 2 of thisLine into recordArray[counter]["date"]
      put item 3 of thisLine into recordArray[counter]["time"]
      put item 5 of thisLine into recordArray[counter]["facets"]
   end repeat
   
   set the dgData of group "recordsGrid" to recordArray
end fillRecordsGrid

on deleteRecord theDGLine
   put line theDGLine of allRecords into theRecord
   
   put "Are you sure you want to delete the quiz results for @nickname from @date at @time?" into theQuestion
   put item 1 of theRecord into nickname
   set the itemDel to ","
   put item 1 of nickname into nickname
   replace "@nickname" with nickname in theQuestion
   set the itemDel to tab
   replace "@date" with item 2 of theRecord in theQuestion
   replace "@time" with item 3 of theRecord in theQuestion
   
   answer theQuestion with "DELETE" or "CANCEL"
   
   if it is "CANCEL" then exit deleteRecord
   
   delete line theDGLine of allRecords
   saveRecords allRecords
   dispatch "deleteline" to group "recordsGrid" with theDGLine
end deleteRecord

on viewReport theDGLine
   put line theDGLine of allRecords into theRecord
   set the itemDel to tab
   put item 1 of theRecord into fld "profile" of card "results"
   put item 4 of theRecord into fld "facetArray" of card "results"
   goCard "results"
   dispatch "createReport" to card "results"
end viewReport

yeldarb
Posts: 43
Joined: Thu Dec 14, 2017 5:39 pm

Re: dispatch "DeleteLine" to group not working

Post by yeldarb » Fri Dec 29, 2017 3:23 pm

Nevermind... I had the "Persistent Data" box ticked. Unchecked it, and now it's working as expected.

:roll:

quailcreek
Posts: 717
Joined: Sun Feb 04, 2007 11:01 pm
Location: McKenna, WA

Re: dispatch "DeleteLine" to group not working

Post by quailcreek » Fri Dec 29, 2017 9:46 pm

Sorry, I thought when you said that there was a btn in the DG that the code was in the DG too.
Tom
MacBook Pro OS High Sierra 10.13.5

Post Reply

Return to “Getting Started with LiveCode - Experienced Developers”