andyhill
uniGUI Subscriber-
Posts
1464 -
Joined
-
Last visited
-
Days Won
8
andyhill's Achievements
Advanced Member (4/4)
65
Reputation
-
SOLVED WITH A WORK AROUND. Farshad, this one is in your court. Because TUniComboBox has a dual personality (Items.Add OR IconItems.Add), when it is assigned as a grid editor, the grid initialisation process samples the items within to determine how to set it up and use. eg. 1 cbItems.Items.Add('1') grid will ignore icons (they do not exist) in grid rendering even if later cbItems are cleared (Items.Clear/IconItems.Clear) and new Iconitems are added, the grid remains locked in non Icon mode. eg. 2 Item:= TUniComboBoxExtended(cbItems).IconItems.Add(); Item.Caption:= '2'; Item.ImageIndex:= 2; Grid will render icons accordingly ONLY IF IN FORMCREATE cbItems IS SEEDED WITH IconItems.Add before assigning to grid. THERFORE if cbItems on creation remains EMPTY or does not contain IconItems before it is assigned to the grid as an editor, Icons throughout the session will be ignored. FIX FOR NOW, on creation seed it with IconItems.Add before assigning it to the grid as an editor.
-
Sherzod, on a standalone shell project with an IDE placed Grid and then dynamically creating the ComboBox - all works as expected. In a much larger project with dynamically created Grids, ComboBoxs etc. (same combo code) dropdown fails to show icons in the dropdown. Do you have some sort of console code that at runtime will read ALL of the grid's settings (including events) so that I can compare to see why the larger projects icons fail to show. It has something to do with the Grid Editor implementation.
-
While I have been waiting, I can fudge Icons in a simple ComboBox test project but in a larger application where a grid is involved "Columns.Items[i].Editor:= cbItems;" the code still executes but the icons fail to appear ? type TUniComboBoxExtended = class(TUniCustomComboBox); ... FORMCREATE cbItems:= TUniComboBox.Create(HiddenPanel); cbItems.Parent:= HiddenPanel; cbItems.Name:= 'cbItems'; cbItems.Mode:= umNameOnly; cbItems.Images:= UniNativeImageList1; cbItems.Items.Clear; cbItems.Text:= ''; cbItems.IconItems.Clear; ... PROCEDURE var Item: TUniIconItem; begin cbItems.BeginUpdate; cbItems.Items.Clear; cbItems.IconItems.Clear; for I:= 1 to 5 do begin Item:= TUniComboBoxExtended(cbItems).IconItems.Add(); Item.Caption:= 'Andy'+IntToStr(I); Item.ImageIndex:= 1; end; cbItems.EndUpdate; end; ... Sherzod, Can you please explain ?
-
Thank you Sherzod HOWEVER the incremental search is now broken (when a key is typed the items list is no longer filtered and synced in dropdown) because of html script ? //i:= cbItems.Items.Add(Str); i:= cbItems.Items.Add('<font color="blue">'+Str+'</font>'); Also, the classical use of icons in a ComboBox was not addressed ? Please advise
-
Sherzod, Originally I added html tags to the dropdown text but needed to strip the tags out when saved (or searched) as grid data BUT had issues. So in the meantime I wanted to try and use the TUniComboBox to handle assigned icons from the UniNativeImageList1 just like the code I posted above but that FAILS. Can we get the UniNativeImageList1 concept code to work please. Also If I go back to the original concept (later I will need to do this elsewhere) I would need to rework my already reconfigure search code below:- grdWorkSheet.JSInterface.JSAddListener('reconfigure', 'function reconfigure(sender, store, columns, oldStore, oldColumns, eOpts) '+ '{ '+ ' columns.forEach(function(col) '+ ' { '+ ' var ed=col.getEditor(); '+ ' if (ed.xtype === "combo") '+ ' { '+ ' ed.addListener("select", '+ ' function (combo, record) '+ ' { '+ ' var _cRow = sender.getSelectionModel().getCurrentPosition().row; '+ ' var _cCol = sender.getSelectionModel().getCurrentPosition().column; '+ ' _cCol+=1; '+ ' /* Take into account the count of hidden columns 0=ID(hidden), 1=InvoiceID(hidden), 2=Quantity, 3=Description, 4=BASType */ '+ ' _cCol-=2; '+ ' Ext.defer(function(){sender.editingPlugin.completeEdit()}, 10); '+ ' Ext.defer(function(){sender.editingPlugin.startEdit(_cRow, _cCol)}, 20); '+ ' } '+ ' ) '+ ' } '+ ' } '+ ' ) '+ '} ' ); By adding your code too making it one code block:- function reconfigure(sender, store, columns, oldStore, oldColumns, eOpts) { columns.forEach(function(col) { var editor = col.getEditor && col.getEditor(); if (editor && editor.xtype === 'combo' && !editor._cleanHandlerAttached) { editor._cleanHandlerAttached = true; editor.on('select', function(combo, record) { var tmp = document.createElement('div'); tmp.innerHTML = combo.getRawValue(); var cleanText = (tmp.textContent || tmp.innerText || '').trim(); combo.setRawValue(cleanText); }); } }); } Can you please merge the reconfigure codes so I can use this idea elsewhere AND get the UniNativeImageList1 concept to work. Thanks Andy
-
Sure cbItems are created at runtime (cbItems.Images:= UniNativeImageList1; // UniImageList) and are cleared and updated on the fly subject to user intervention. cbItems.BeginUpdate; cbItems.Items.Clear; if UniMainModule.MyQuery1.Active then UniMainModule.MyQuery1.Close; UniMainModule.MyQuery1.SQL.Clear; UniMainModule.MyQuery1.Params.Clear; UniMainModule.MyQuery1.SQL.Add('SELECT Description '+ 'FROM '+UniMainModule.ActiveDatabase+'.Items '+ 'WHERE HideFromView <> TRUE '+ 'AND UPPER(BusinessName) = :TXT '+ 'ORDER BY Description ;'); UniMainModule.MyQuery1.ParamByName('TXT').AsString:= UpperCase(PurchSupplier); UniMainModule.MyQuery1.Open; while not UniMainModule.MyQuery1.Eof do begin i:= cbItems.Items.Add(Trim(UniMainModule.MyQuery1.FieldByName('Description').AsString)); cbItems.Items[i].IconIndex:= 1; <<<<< etc. UniMainModule.MyQuery1.Next; end; UniMainModule.MyQuery1.Close; cbItems.EndUpdate; This would be consistent with other similar programming.
-
Off memory this is how I use WebSockets for data synchronizing among active sessions. SERVERMODULE procedure TUniServerModule.UniGUIServerModuleBeforeInit(Sender: TObject); ... // REQUIRED BY CLOUDFLARE (otherwise use normal SSL) WebSocketServer.AlwaysUseHTTP:= True; ... end; // UniGUIServerModuleBeforeInit MAINMODULE procedure TUniMainModule.UniGUIMainModuleCreate(Sender: TObject); ... // ENABLE WEBSOCKET COMMUNICATION FOR THIS SESSION WebSocketConnection.Enabled:= True; ... end; // UniGUIMainModuleCreate MAINFORM ... // NEED TO ADVISE OTHER ACTIVE SESSIONS AS USER HAS JUST UPDATED TABLE (use _tblUpdated_ to identify table) BroadcastMessage('_tblUpdated_', ['SID', UniSession.SessionID]); ... MAINFORM procedure TMainForm.UniFormBroadcastMessage(const Sender: TComponent; const Msg: string; const Params: TUniStrings); ////////////////////////////////////////////////////////////////////////////// if Msg = '_tblUpdated_' then begin if UniMainModule.Table.Active = True then begin ////////////////////////////////////////////////////////////////////////// // VERIFY NOT CALLING MY OWN SESSION s:= Params.Values['SID']; if UniSession.SessionID <> s then begin //////////////////////////////////////////////////////////////////////// // REFRESH MY LOCAL DATA try UniMainModule.Table.Refresh; // REQUIRED FOR CALCULATED FIELDS UniMainModule.dsTable.DataSet.Refresh; // REQUIRED FOR GRID except end; end; // SessionID <> s end; // Active end; // Msg end; // UniFormBroadcastMessage I am sure there are many ways to do this.
-
Sherzod, What I would like to do is add a "Mode" variable (short int) to the Combobox Item (it would have been good if the Delphi Tag was implemented as I could have used that). i:= cbItems.Items.Add('something'); cbItems.Items[i].Mode:= 1; Then have an onPaintItem procedure where the Mode determines the font colour, eg. Mode 0 Black, Mode 1 Blue, Mode 2 Red etc. Can you please show how to do this with working code - Thanks - Andy
