Alexandre Trevizoli Posted September 4, 2023 Share Posted September 4, 2023 Hi! I need to get title click, how I can do that? Thanks Link to comment Share on other sites More sharing options...
Sherzod Posted September 4, 2023 Share Posted September 4, 2023 51 minutes ago, Alexandre Trevizoli said: I need to get title click, how I can do that? Hello, For what purpose? Link to comment Share on other sites More sharing options...
Alexandre Trevizoli Posted September 4, 2023 Author Share Posted September 4, 2023 I have an custom search form, that when user click on title of grid, they can search for that column on an edit field. Link to comment Share on other sites More sharing options...
Sherzod Posted September 5, 2023 Share Posted September 5, 2023 11 hours ago, Alexandre Trevizoli said: I have an custom search form, that when user click on title of grid, they can search for that column on an edit field. Try this approach: 1. UnimDBGrid1.ClientEvents.ExtEvents -> function painted(sender, eOpts) { sender.getColumns().forEach( function(col){ if (col.headerElement) { col.headerElement.addListener('click', function(a,b) { if (b.classList[0] && (b.classList[0].indexOf('x-header-el') == 0 || b.classList[0].indexOf('x-text-el') == 0)) { ajaxRequest(sender, 'titleClick', {colIndx: col.getDataIndex()}) } }) } }); } 2. UniDBGrid1.OnAjaxEvent -> procedure TMainmForm.UnimDBGrid1AjaxEvent(Sender: TComponent; EventName: string; Params: TUniStrings); begin if EventName = 'titleClick' then ShowMessage(Params.Values['colIndx']) end; Link to comment Share on other sites More sharing options...
Alexandre Trevizoli Posted September 5, 2023 Author Share Posted September 5, 2023 11 hours ago, Sherzod said: Try this approach: 1. UnimDBGrid1.ClientEvents.ExtEvents -> function painted(sender, eOpts) { sender.getColumns().forEach( function(col){ if (col.headerElement) { col.headerElement.addListener('click', function(a,b) { if (b.classList[0] && (b.classList[0].indexOf('x-header-el') == 0 || b.classList[0].indexOf('x-text-el') == 0)) { ajaxRequest(sender, 'titleClick', {colIndx: col.getDataIndex()}) } }) } }); } 2. UniDBGrid1.OnAjaxEvent -> procedure TMainmForm.UnimDBGrid1AjaxEvent(Sender: TComponent; EventName: string; Params: TUniStrings); begin if EventName = 'titleClick' then ShowMessage(Params.Values['colIndx']) end; It's worked! I make an simple change taking out this if (b.classList[0] && (b.classList[0].indexOf('x-header-el') == 0 || b.classList[0].indexOf('x-text-el') == 0)) because some places that I click the listener not work, after taking out, work on every place of title. But I tested that if I make some change on Title font color on runtime (when I click, in my original code, I change font color to Marron) listener is lost. Could or Should I add it again after some change on grid? How? Thanks a lot! I think you could put this on roadmap of mobile development. Link to comment Share on other sites More sharing options...
Recommended Posts