closeFieldEditor & RefreshLine

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
townsend
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 430
Joined: Sun Feb 13, 2011 8:43 pm

closeFieldEditor & RefreshLine

Post by townsend » Mon May 23, 2011 9:24 pm

I've got a dataGrid called myGrid. There are two columns, ID and Name.

I doublelick to edit the Name field. And the closeFieldEditor Handler happens

Code: Select all

on closeFieldEditor
     put the dgHilitedLines of group "mygrid" into theLine
     put the dgDataOfLine[theLine] of group "mygrid" into theDataA
     --send RefreshLine to me  -- (this doesn't work)
     answer theDataA["id"] && theDataA["Name"]
end closeFieldEditor
The Answer function displays both the ID and the Name.
BUT it's the original Name. NOT the newly edited name.

I've tried many variations of Send RefreshLine to to get the
row updated before the Answer function. No luck there.
What's the correct syntax on that?

I know if I use an pFieldEditor parameter, I can grab the updated
Name value from pFieldEditor, but I'd rather not go that route, as it
adds another level of complexity, especially with multi field rows.

Is it possible to refresh the line before the end closeFieldEditor
handler is complete?

PS: once I get the correct values through the Awsnser function
then I can use them in a SQL command.

dglass
Posts: 519
Joined: Thu Sep 24, 2009 9:10 pm
Contact:

Re: closeFieldEditor & RefreshLine

Post by dglass » Mon May 23, 2011 9:44 pm

A guess:

The data in the line isn't really updated until closeFieldEditor completes. By calling RefreshLine from within closeFieldEditor you are delaying that from happening.

Perhaps a

send RefreshLine to me in 10 milliseconds

would help, by putting the RefreshLine 'in the queue', and allowing closeFieldEditor to finish and update the data.

Again, just a guess.

townsend
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 430
Joined: Sun Feb 13, 2011 8:43 pm

Re: closeFieldEditor & RefreshLine

Post by townsend » Mon May 23, 2011 9:51 pm

Thanks dglass for your quick reply.

That sounds equally akward. Are you suggesting that using
the text of the pFieldEditor would be the best practice?

What happens when you have a row with many fields. Sure
the text of pFieldEditor contains the updated value, but how
are you supposes to know which field or column it came from?

dglass
Posts: 519
Joined: Thu Sep 24, 2009 9:10 pm
Contact:

Re: closeFieldEditor & RefreshLine

Post by dglass » Mon May 23, 2011 10:07 pm

I don't know what the best practice would be. Somebody with more time with LC would have to answer that one.

As for the other question...

When the editing of the cell starts I think you should have access to the column and line number, right? If so, store them for use in determining which field/column/record needs updating in your DB (or wherever).

If not, well, I don't know... :|

Simon Knight
Posts: 919
Joined: Wed Nov 04, 2009 11:41 am

Re: closeFieldEditor & RefreshLine

Post by Simon Knight » Sat May 28, 2011 5:51 pm

Hi Townsend,

Have you found a solution to your original question? I am having similar problems : I have code that validates the user entry in a cell by adding code to the closefieldeditor it works but when I add code to save the new entry, extracted from the text of pfieldEditor, the update of the field fails and the old data remains - very odd.

I keep thinking that it shouldn't be this difficult or I must have missed something in the documentation. :(

best wishes

Simon
best wishes
Skids

Post Reply