picyka Posted June 18, 2022 Author Share Posted June 18, 2022 8 minutos atrás, Sherzod disse: Sim. Tell us the magic, please, you're making a suspense lol Quote Link to comment Share on other sites More sharing options...
Sherzod Posted June 18, 2022 Share Posted June 18, 2022 1 hour ago, picyka said: Tell us the magic, please, you're making a suspense lol Can you try this approach? unit uniCheckComboBoxTest; interface uses Data.DB, System.SysUtils, System.Classes, Vcl.Controls, Vcl.Forms, uniGUIBaseClasses, uniGUIClasses, uniMultiItem, uniComboBox, System.Variants, uniGUIApplication, Winapi.Windows, System.Generics.Collections, uniCheckBox, System.StrUtils, uniGUITypes; type TUniCheckComboBoxCustom = class(TUniCheckComboBox) private { Private declarations } //FCheckBox: TUniCheckBox; FCheckBoxChecked: Boolean; procedure CreateCheckBox; procedure SetCheckBoxChecked(const Value: Boolean); protected { Protected declarations } procedure JSEventHandler(AEventName: string; AParams: TUniStrings); override; procedure LoadCompleted; override; public { Public declarations } constructor Create(AOwner: TComponent); override; destructor Destroy; override; //property CheckBox: TUniCheckBox read FCheckBox write FCheckBox; property CheckBoxChecked: Boolean read FCheckBoxChecked write SetCheckBoxChecked; published { Published declarations } end; TUniCheckComboBoxTest = class(TUniCheckComboBoxCustom) end; procedure Register; implementation procedure Register; begin RegisterComponents('UniGUI Extension', [TUniCheckComboBoxTest]); end; { TUniComboBoxObject } constructor TUniCheckComboBoxCustom.Create(AOwner: TComponent); begin inherited Create(AOwner); FCheckBoxChecked := False; //if (not (csDesigning in ComponentState)) then //Self.CreateCheckBox; end; procedure TUniCheckComboBoxCustom.CreateCheckBox; begin // Self.FCheckBox := TUniCheckBox.Create(Self.Owner); // Self.FCheckBox.Parent := TWinControl(Self.Owner); // Self.FCheckBox.Width := 20; // Self.FCheckBox.Caption := ''; // Self.FCheckBox.Hint := 'Exceto'; // Self.FCheckBox.ShowHint := True; end; destructor TUniCheckComboBoxCustom.Destroy; begin inherited Destroy; end; procedure TUniCheckComboBoxCustom.JSEventHandler(AEventName: string; AParams: TUniStrings); begin inherited; if AEventName = '_checked' then FCheckBoxChecked := AParams.Values['checked'] = 'true'; end; procedure TUniCheckComboBoxCustom.LoadCompleted; begin inherited; //Self.FCheckBox.JSInterface.JSCall('alignTo', [Self.JSControl, 'tr?', JSInterface.JSStatement('[-35, 0]')]); JSInterface.JSCode(#1'.checkBoxEl = Ext.dom.Helper.insertBefore('#1'.inputEl, {'+ 'tag: "input", type: "checkbox"'+ IfThen(FCheckBoxChecked, ', checked: "checked"', '') + ',onclick: "ajaxRequest('#1', ''_checked'', {checked: this.checked})"'+ ',style: "position: absolute; font-size: 1.4em; bottom: 0; right: -3px; top: 1px;"'+ '}); ' ) end; procedure TUniCheckComboBoxCustom.SetCheckBoxChecked(const Value: Boolean); begin FCheckBoxChecked := Value; if not IsLoading then JSAssign('checkBoxEl.checked', [FCheckBoxChecked]); end; end. Quote Link to comment Share on other sites More sharing options...
picyka Posted June 18, 2022 Author Share Posted June 18, 2022 39 minutes ago, Sherzod said: Can you try this approach? unit uniCheckComboBoxTest; interface uses Data.DB, System.SysUtils, System.Classes, Vcl.Controls, Vcl.Forms, uniGUIBaseClasses, uniGUIClasses, uniMultiItem, uniComboBox, System.Variants, uniGUIApplication, Winapi.Windows, System.Generics.Collections, uniCheckBox, System.StrUtils, uniGUITypes; type TUniCheckComboBoxCustom = class(TUniCheckComboBox) private { Private declarations } //FCheckBox: TUniCheckBox; FCheckBoxChecked: Boolean; procedure CreateCheckBox; procedure SetCheckBoxChecked(const Value: Boolean); protected { Protected declarations } procedure JSEventHandler(AEventName: string; AParams: TUniStrings); override; procedure LoadCompleted; override; public { Public declarations } constructor Create(AOwner: TComponent); override; destructor Destroy; override; //property CheckBox: TUniCheckBox read FCheckBox write FCheckBox; property CheckBoxChecked: Boolean read FCheckBoxChecked write SetCheckBoxChecked; published { Published declarations } end; TUniCheckComboBoxTest = class(TUniCheckComboBoxCustom) end; procedure Register; implementation procedure Register; begin RegisterComponents('UniGUI Extension', [TUniCheckComboBoxTest]); end; { TUniComboBoxObject } constructor TUniCheckComboBoxCustom.Create(AOwner: TComponent); begin inherited Create(AOwner); FCheckBoxChecked := False; //if (not (csDesigning in ComponentState)) then //Self.CreateCheckBox; end; procedure TUniCheckComboBoxCustom.CreateCheckBox; begin // Self.FCheckBox := TUniCheckBox.Create(Self.Owner); // Self.FCheckBox.Parent := TWinControl(Self.Owner); // Self.FCheckBox.Width := 20; // Self.FCheckBox.Caption := ''; // Self.FCheckBox.Hint := 'Exceto'; // Self.FCheckBox.ShowHint := True; end; destructor TUniCheckComboBoxCustom.Destroy; begin inherited Destroy; end; procedure TUniCheckComboBoxCustom.JSEventHandler(AEventName: string; AParams: TUniStrings); begin inherited; if AEventName = '_checked' then FCheckBoxChecked := AParams.Values['checked'] = 'true'; end; procedure TUniCheckComboBoxCustom.LoadCompleted; begin inherited; //Self.FCheckBox.JSInterface.JSCall('alignTo', [Self.JSControl, 'tr?', JSInterface.JSStatement('[-35, 0]')]); JSInterface.JSCode(#1'.checkBoxEl = Ext.dom.Helper.insertBefore('#1'.inputEl, {'+ 'tag: "input", type: "checkbox"'+ IfThen(FCheckBoxChecked, ', checked: "checked"', '') + ',onclick: "ajaxRequest('#1', ''_checked'', {checked: this.checked})"'+ ',style: "position: absolute; font-size: 1.4em; bottom: 0; right: -3px; top: 1px;"'+ '}); ' ) end; procedure TUniCheckComboBoxCustom.SetCheckBoxChecked(const Value: Boolean); begin FCheckBoxChecked := Value; if not IsLoading then JSAssign('checkBoxEl.checked', [FCheckBoxChecked]); end; end. We have the best support in the world here, big hug master 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.