ThiagoFiorilli Posted April 14, 2023 Share Posted April 14, 2023 This is doubt of many friends and mine too. The demo is very simple, it doesn't help. Anyway, how to get the text of the selected item. The ItemIndex property always returns -1 Quote Link to comment Share on other sites More sharing options...
Sherzod Posted April 14, 2023 Share Posted April 14, 2023 3 hours ago, ThiagoFiorilli said: This is doubt of many friends and mine too. The demo is very simple, it doesn't help. Exactly what are you talking about? 3 hours ago, ThiagoFiorilli said: Anyway, how to get the text of the selected item. What do you mean? Explain in more detail. Quote Link to comment Share on other sites More sharing options...
ThiagoFiorilli Posted April 14, 2023 Author Share Posted April 14, 2023 6 hours ago, Sherzod said: Exactly what are you talking about? What do you mean? Explain in more detail. Example: I added in the list: All; A, B, C If checked "All", then check all items, if uncheck "All" then uncheck all items. That way, if I know that the clicked item was "All", then I can do what I need... Quote Link to comment Share on other sites More sharing options...
Sherzod Posted April 14, 2023 Share Posted April 14, 2023 10 minutes ago, ThiagoFiorilli said: That way, if I know that the clicked item was "All" if UniCheckComboBox1.Selected[0] then //selected else //unselected Quote Link to comment Share on other sites More sharing options...
ThiagoFiorilli Posted April 14, 2023 Author Share Posted April 14, 2023 1 hour ago, Sherzod said: if UniCheckComboBox1.Selected[0] then //selected else //unselected But i need run this code only if the user click on the item "All". If he check then select all, if uncheck, then, unselect all... Is it possibel? Quote Link to comment Share on other sites More sharing options...
Sherzod Posted April 14, 2023 Share Posted April 14, 2023 I will check. Quote Link to comment Share on other sites More sharing options...
ThiagoFiorilli Posted April 14, 2023 Author Share Posted April 14, 2023 19 minutes ago, Sherzod said: I will check. Thank you, Sherzod. I'll wait your answer... Quote Link to comment Share on other sites More sharing options...
Sherzod Posted April 14, 2023 Share Posted April 14, 2023 @ThiagoFiorilli Maybe you will use this approach? Quote Link to comment Share on other sites More sharing options...
ThiagoFiorilli Posted April 14, 2023 Author Share Posted April 14, 2023 8 minutes ago, Sherzod said: @ThiagoFiorilli Maybe you will use this approach? I would not like to use a button; only on the click or onselect of the unicheckComboBox. Quote Link to comment Share on other sites More sharing options...
andyhill Posted April 14, 2023 Share Posted April 14, 2023 This is how I would do it // OnSelect Event procedure TMainForm.UniCheckComboBox1Select(Sender: TObject); var s: String; i: Integer; begin s:= ''; for i:= 0 to (Sender as TUniCheckComboBox).Items.Count-1 do begin if (Sender as TUniCheckComboBox).Selected[i] = True then begin s:= s + IntToStr(i)+': '+(Sender as TUniCheckComboBox).Items[i]+#10; end; end; ShowMessage(s); end; Quote Link to comment Share on other sites More sharing options...
Sherzod Posted April 15, 2023 Share Posted April 15, 2023 15 hours ago, ThiagoFiorilli said: I would not like to use a button; only on the click or onselect of the unicheckComboBox. Some progress: 1 Quote Link to comment Share on other sites More sharing options...
picyka Posted April 15, 2023 Share Posted April 15, 2023 😍👀 Quote Link to comment Share on other sites More sharing options...
Sherzod Posted April 15, 2023 Share Posted April 15, 2023 Quote Link to comment Share on other sites More sharing options...
Sherzod Posted April 15, 2023 Share Posted April 15, 2023 Remains the logic for single selection, deselection and determining the states of the "checkbox"... If this is not important, then I will share what I have at the moment. Quote Link to comment Share on other sites More sharing options...
Sherzod Posted April 15, 2023 Share Posted April 15, 2023 @ThiagoFiorilli @picyka Can you please test this approach? 1. UniCheckComboBox1.ClientEvents.ExtEvents -> function afterrender(sender, eOpts) { var me = sender; var _insertCheckbox = function() { var _id = me.getPicker().id; Ext.DomHelper.insertFirst(_id, { tag: 'label', for: _id + '_allCh', html: 'AllCheck/AllUnCheck<hr>' }); Ext.DomHelper.insertFirst(_id, { tag: 'input', type: 'checkbox', id: _id + '_allCh' }); Ext.get(_id + '_allCh').on('change', function(e, combo) { ajaxRequest(me, 'allCheckUnCheck', { checked: combo.checked.toString() }); }); me.on('change', function(combo, b) { if (combo.getStore().count() == b.length) { Ext.get(_id + '_allCh').dom.checked = true } else { Ext.get(_id + '_allCh').dom.checked = false } }, { delegate: '.x-boundlist-item' }); me.getPicker().un('show', _insertCheckbox); }; me.getPicker().on('show', _insertCheckbox); } 2. UniCheckComboBox1.OnAjaxEvent -> procedure TMainForm.UniCheckComboBox1AjaxEvent(Sender: TComponent; EventName: string; Params: TUniStrings); var I: Integer; begin if EventName = 'allCheckUnCheck' then begin if Params.Values['checked'] = 'true' then begin for I := 0 to (Sender as TUniCheckComboBox).Items.Count-1 do (Sender as TUniCheckComboBox).Selected[I] := True; (Sender as TUniCheckComboBox).JSInterface.JSCall('fireEvent', ['select', (Sender as TUniCheckComboBox).JSControl]); end else begin (Sender as TUniCheckComboBox).ClearSelection; end; end; end; 1 1 Quote Link to comment Share on other sites More sharing options...
ThiagoFiorilli Posted April 16, 2023 Author Share Posted April 16, 2023 Hello, Sherzod! I performed tests and the solution fits my needs perfectly. Thanks for working on it. 1 Quote Link to comment Share on other sites More sharing options...
Abaksoft Posted April 16, 2023 Share Posted April 16, 2023 On 4/15/2023 at 8:53 PM, Sherzod said: @ThiagoFiorilli @picyka Can you please test this approach? 1. UniCheckComboBox1.ClientEvents.ExtEvents -> function afterrender(sender, eOpts) { var me = sender; var _insertCheckbox = function() { var _id = me.getPicker().id; Ext.DomHelper.insertFirst(_id, { tag: 'label', for: _id + '_allCh', html: 'AllCheck/AllUnCheck<hr>' }); Ext.DomHelper.insertFirst(_id, { tag: 'input', type: 'checkbox', id: _id + '_allCh' }); Ext.get(_id + '_allCh').on('change', function(e, combo) { ajaxRequest(me, 'allCheckUnCheck', { checked: combo.checked.toString() }); }); me.on('change', function(combo, b) { if (combo.getStore().count() == b.length) { Ext.get(_id + '_allCh').dom.checked = true } else { Ext.get(_id + '_allCh').dom.checked = false } }, { delegate: '.x-boundlist-item' }); me.getPicker().un('show', _insertCheckbox); }; me.getPicker().on('show', _insertCheckbox); } 2. UniCheckComboBox1.OnAjaxEvent -> procedure TMainForm.UniCheckComboBox1AjaxEvent(Sender: TComponent; EventName: string; Params: TUniStrings); var I: Integer; begin if EventName = 'allCheckUnCheck' then begin if Params.Values['checked'] = 'true' then begin for I := 0 to (Sender as TUniCheckComboBox).Items.Count-1 do (Sender as TUniCheckComboBox).Selected[I] := True; (Sender as TUniCheckComboBox).JSInterface.JSCall('fireEvent', ['select', (Sender as TUniCheckComboBox).JSControl]); end else begin (Sender as TUniCheckComboBox).ClearSelection; end; end; end; Many Thx Sherzod... 1 Quote Link to comment Share on other sites More sharing options...
Sherzod Posted May 17, 2023 Share Posted May 17, 2023 Hello @picyka @ThiagoFiorilli @Abaksoft You may also need this customCSS: .x-boundlist { height: auto !important; } 1 Quote Link to comment Share on other sites More sharing options...
picyka Posted May 17, 2023 Share Posted May 17, 2023 4 horas atrás, Sherzod disse: Olá @picyka @ThiagoFiorilli @Abaksoft Você também pode precisar deste CSS personalizado: .x-boundlist { height: auto !important; } perfect, thank you for always helping us. 1 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.