fabiorov Posted January 2, 2018 Share Posted January 2, 2018 Hi Usually I need to hide columns to the user (because it has some DB tables key values that are not recommended to show), so I do: Dbgrid.columns[x].visible:=False; The problem is that user can go to the upper tittle bar of DBgrid and enable them, so is there a final method to not allow the user to enable the not-visible columns? Quote Link to comment Share on other sites More sharing options...
Sherzod Posted January 2, 2018 Share Posted January 2, 2018 Hi, You can use like this, for example: Hidden column index = 0 1. Columns[0].Visible := False; 2. UniDBGrid -> ClientEvents -> ExtEvents -> function reconfigure: function reconfigure(sender, store, columns, oldStore, oldColumns, eOpts) { columns[0].hideable=false; } Best regards, Quote Link to comment Share on other sites More sharing options...
gastelumri Posted November 25, 2020 Share Posted November 25, 2020 Thank you @Sherzod It works at design environment How to do it on run time? Quote Link to comment Share on other sites More sharing options...
Sherzod Posted November 25, 2020 Share Posted November 25, 2020 11 minutes ago, gastelumri said: How to do it on run time? Hide column? Quote Link to comment Share on other sites More sharing options...
bdiri Posted November 25, 2020 Share Posted November 25, 2020 Hi gastelumri try UniDBGrid1.Columns[0].Visible:=false; UniDBGrid1.Columns[0].Menu.ColumnHideable := False; Quote Link to comment Share on other sites More sharing options...
gastelumri Posted November 25, 2020 Share Posted November 25, 2020 1 hour ago, bdiri said: UniDBGrid1.Columns[0].Visible:=false; UniDBGrid1.Columns[0].Menu.ColumnHideable := False; May work, but will need the part that is set on IDE (UniDBGrid -> ClientEvents -> ExtEvents -> function reconfigure) 4 hours ago, Sherzod said: Hide column? Yes, hide the column, something like the below code procedure TMainForm.UniBitBtn1Click(Sender: TObject); begin UniDBGrid1.ClientEvents.Enabled:=false; UniDBGrid1.ClientEvents.ExtEvents.Clear; UniDBGrid1.ClientEvents.Enabled:=true; UniDBGrid1.ClientEvents.ExtEvents.Values['reconfigure']:= 'function reconfigure(sender, store, columns, oldStore, oldColumns, eOpts) ' + ' { columns[0].hideable=false; }'; //UniDBGrid1.ClientEvents.ExtEvents.Values['activate']:= 'function activate(sender, eOpts) { }'; end; Quote Link to comment Share on other sites More sharing options...
diegojmap Posted November 25, 2020 Share Posted November 25, 2020 I used DBGrid1.JSInterface.JSCall ('setVisible', [False], DBGrid1.Columns [13] .JSColumn); DBGrid1.JSInterface.JSCall ('setVisible', [False], DBGrid1.Columns [16] .JSColumn); Quote Link to comment Share on other sites More sharing options...
gastelumri Posted November 26, 2020 Share Posted November 26, 2020 The goal is to remove the option for the end user, and have control of showing / hiding the column, without it being an end user option I will use a combination of yours codes Thank you very much gentlemen Quote Link to comment Share on other sites More sharing options...
Pier Posted February 27, 2021 Share Posted February 27, 2021 can you please post your final code? 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.