Icon View Thread

The following is the text of the current message along with any replies.
Messages 1 to 7 of 7 total
Thread TGrid/TDataSet .Empty oddity
Mon, May 23 2016 9:35 AMPermanent Link

Matthew Jones

I have a slightly odd one here, and wonder if others have seen it. I
have a search that calls the server to get data for display in a grid.
This works fine if things are found, but if nothing is found, the grid
keeps showing the old content until I move the mouse over it, and then
it disappears. If there is actually new content, it appears instantly.

Any suggestions why this might happen? I do sometimes get a mouse move
event exception, but having trouble pinning that down again as I
figured it wasn't relevant, but it probably is.

My code, in case anyone can see something wrong with it:


procedure TfrmLibrary.LoadlibraryItems(szJSON : String);
var
   nLoop : Integer;
   xItem : TLibraryCommon;
begin                                      
   dsItems.Open;
   try                                 
       DebugReport('TfrmLibrary.LoadlibraryItems "' + szJSON + '"');

       dsItems.BeginControlUpdate;
       dsItems.Empty;

       m_xLibraryList.Clear;
       m_xLibraryList.SetJSON(szJSON);
       DebugReport('m_xLibraryList.Count' +
IntToStr(m_xLibraryList.Count));

       for nLoop := 0 to m_xLibraryList.Count - 1 do
       begin
           xItem := m_xLibraryList.Items[nLoop];
           dsItems.Insert(true);
           dsItems.Columns.Column['dsDesc'].AsString :=
xItem.HumanDescriptionTXT;
           dsItems.Columns.Column['dsUnit'].AsString :=
xItem.MeasurementUNIT;
           dsItems.Columns.Column['dsRate'].AsString :=
CurrencyDisplay(xItem.LineRateCur);
       end;

   finally
       DebugReport('EndControlUpdate');
       dsItems.EndControlUpdate;
   end;
   dsItems.First;
end;


--

Matthew Jones
Mon, May 23 2016 10:59 AMPermanent Link

Roy Lambert

NLH Associates

Team Elevate Team Elevate

Matthew


On the basis I'm not an EWB user I could be totally and utterly wrong but here goes for a guess. Reverse the order of these two lines

       dsItems.BeginControlUpdate;
       dsItems.Empty;

My interpretation is that you stop the control responding to the table and then change it. If you add new items in then as soon as hits dsItems.EndControlUpdate; then it knows there have been changes and does an update otherwise not.

Roy Lambert
Mon, May 23 2016 11:43 AMPermanent Link

Matthew Jones

Matthew Jones wrote:

>  I do sometimes get a mouse move
> event exception, but having trouble pinning that down again as I
> figured it wasn't relevant, but it probably is.

Chrome stack:

webui_telement.$p.triggerevent (myfile.js:13277)
webui_teventmanager.$p.mouseenterhandler (myfile.js:16350)
(anonymous function) (myfile.js:265)

(and it appears that Roy has the fix...)

--

Matthew Jones
Mon, May 23 2016 11:44 AMPermanent Link

Matthew Jones

Roy Lambert wrote:

> On the basis I'm not an EWB user I could be totally and utterly wrong
> but here goes for a guess. Reverse the order of these two lines
>
>         dsItems.BeginControlUpdate;
>         dsItems.Empty;
>
> My interpretation is that you stop the control responding to the
> table and then change it. If you add new items in then as soon as
> hits dsItems.EndControlUpdate; then it knows there have been changes
> and does an update otherwise not.

And that does indeed fix it - instant update.

Strikes me as a bug, but easy workaround.

--

Matthew Jones
Mon, May 23 2016 12:49 PMPermanent Link

Tim Young [Elevate Software]

Elevate Software, Inc.

Avatar

Email timyoung@elevatesoft.com

Matthew,

<< Strikes me as a bug, but easy workaround. >>

You're not using the correct method.  What you want is DisableControls/EnableControls, not BeginControlUpdate/EndControlUpdate.  BeginControlUpdate/EndControlUpdate are specifically for use by data-bound controls:

http://www.elevatesoft.com/manual?action=viewmethod&id=ewb2&comp=TDataSet&method=BeginControlUpdate

Tim Young
Elevate Software
www.elevatesoft.com
Tue, May 24 2016 4:25 AMPermanent Link

Matthew Jones

Tim Young [Elevate Software] wrote:

> You're not using the correct method.  What you want is
> DisableControls/EnableControls, not
> BeginControlUpdate/EndControlUpdate.
> BeginControlUpdate/EndControlUpdate are specifically for use by
> data-bound controls:
>
>
http://www.elevatesoft.com/manual?action=viewmethod&id=ewb2&comp=TDataSet&method=BeginControlUpdate


I've read the texts, but I'm not sure I really understand the
difference. There is a warning that one is for component developers,
and a technical explanation, but the consequences escape me, other than
the behaviour that didn't happen for me. 8-)

Anyway, key is that this thread now exists for others to find the
answer in.

--

Matthew Jones
Tue, May 24 2016 10:54 AMPermanent Link

Tim Young [Elevate Software]

Elevate Software, Inc.

Avatar

Email timyoung@elevatesoft.com

Matthew,

<< I've read the texts, but I'm not sure I really understand the difference. There is a warning that one is for component developers, and a technical explanation, but the consequences escape me, other than the behaviour that didn't happen for me. 8-) >>

The key part is about being for component developers - EnableControls causes a notification to all controls that refreshes them, whereas EndControlUpdate does not.  The reason why is that BeginControlUpdate/EndControlUpdate are used during updates to multi-line controls, such as grids, that need to navigate the underlying dataset without triggering any events, control updates, etc.

Tim Young
Elevate Software
www.elevatesoft.com
Image