Dataset enter in "Edit" mode if there is a DBLookupComboBox
Original Reporter info from Mantis:
-
Reporter name:
Original Reporter info from Mantis:
- Reporter name:
Description:
If there is a DBLookupComboBox, placed on a form which is related to main dataset field and lookup data set field, when the maindataset is opened or scrolled , it goes to "Edit" mode, which is not expected.
After some analysts, I found, that the reason is because cocoa widget fires "OnSelectected" event into CustomComboBox, which triggers "FDatalink.Edit" method.
In fact, there is selection change, because when main dataset "changes" combobox text (because of open or scroll), but it is not user change, and must not fire "OnSelected" event.
Steps to reproduce:
Create a simple project with a two MemoryDataSet Components. Name one of that "MainDs", another one - "LookupDs". Add in MainDs field called "ID", into lookupDs- two fields - L_ID and L_STRING(255).
Put two datasources on the form, ling them to the datasets.
Place some DBGrid on form (just for watching) and link it to the datasource related to MainDs.
Place a DBLookupComboBox control and set the properties: Datasource to the MainDs datasource, LookupSource to the LookupDS datasource. SetDataField to field ID from MainDS, KeyField to L_ID and ListField to L_STRING.
Add the following code on "FormCreate" event:
LookupDs.CreateTable;
LookupDs.Open;
MainDs.CreateTable;
MainDs.Open;
MAinDs.Append;
MAinDs.FieldByName('ID').Value := 1;
MAinDs.Post;
MAinDs.Append;
MAinDs.FieldByName('ID').Value := 2;
MAinDs.Post;
LookupDs.Append;
LookupDs.FieldByName('L_ID').Value := 1;
LookupDs.FieldByName('L_STRING').Value := 'String 1';
LookupDs.Post;
LookupDs.Append;
LookupDs.FieldByName('L_ID').Value := 2;
LookupDs.FieldByName('L_STRING').Value := 'String 2';
LookupDs.Post;
Compile and start the App. You will immediately see that the DBGrid is into "Edit" mode.
Scroll the cursor to the second DBGrid row and again maindataset will be into Edit mode.
I tested the same project under Windows, Ubuntu (GTK2), OS X (Carbon) and there is no problem.
Additional information:
Please find attached simple test project.
Mantis conversion info:
- Mantis ID: 33800
- OS: Mac OS X
- OS Build: Siera
- Build: Trunk
- Platform: Cocoa
- Fixed in version: 1.9 (SVN)
- Fixed in revision: 59252 (#de1fe8d7)
- Target version: 1.10