mos Posted November 20, 2018 Share Posted November 20, 2018 I have an application that populates a TUniStringGrid dynamically and the data is loaded based on the selected item from a specific list. Which could be solved by any of the 2 situations below: 1. How can I execute a line of JS code? or 2. How can I hide a column completely? Since there is no Visible property in Columns (only used Columns.width := 0) To elaborate: 1. The javascript is like this, $('.test').each(function () { $(this).css('display', $(this).width() == 0 ? 'none' : ''); }); I've tried UniStringGrid.JSInterface.JSCode('code here'); But it doesn't run. Alternatively, I've also used the ClientEvents.ExtEvents property, but this only works on the initial loading (placed on afterlayout) but when the data is changed, doesn't run anymore. 2. The columns appear as the image below Either solution to the 2 problems above would be great! Thanks! Quote Link to comment Share on other sites More sharing options...
Sherzod Posted November 20, 2018 Share Posted November 20, 2018 Hi, Maybe I don't fully understand what you want, In addition..., you can also use this JS event: function store.datachanged(sender, eOpts) { // } Quote Link to comment Share on other sites More sharing options...
mos Posted November 20, 2018 Author Share Posted November 20, 2018 2 minutes ago, Sherzod said: Hi, Maybe I don't fully understand what you want, In addition..., you can also use this JS event: function store.datachanged(sender, eOpts) { // } Hi, It's actually either one of the following: 1. Where or how can I run the javascript I need to run? or 2. How can I hide a column completely? There is no visible property in columns Quote Link to comment Share on other sites More sharing options...
Sherzod Posted November 20, 2018 Share Posted November 20, 2018 17 minutes ago, mos said: 2. How can I hide a column completely? There is no visible property in columns Maybe something like this: // for example, the second column UniStringGrid1.JSInterface.JSCall('getColumns()[1].setHidden', [True]); Quote Link to comment Share on other sites More sharing options...
mos Posted November 20, 2018 Author Share Posted November 20, 2018 35 minutes ago, Sherzod said: Maybe something like this: // for example, the second column UniStringGrid1.JSInterface.JSCall('getColumns()[1].setHidden', [True]); Hi, tried this but i get an error Quote Link to comment Share on other sites More sharing options...
Sherzod Posted November 20, 2018 Share Posted November 20, 2018 Can you make a simple testcase ?! Quote Link to comment Share on other sites More sharing options...
Sherzod Posted November 20, 2018 Share Posted November 20, 2018 10 minutes ago, mos said: tried this but i get an error On MainForm -> OnCreate event ?! Quote Link to comment Share on other sites More sharing options...
Sherzod Posted November 20, 2018 Share Posted November 20, 2018 48 minutes ago, mos said: tried this but i get an error Also, you can try this approach: function reconfigure(sender, store, columns, oldStore, oldColumns, eOpts) { columns[1].hidden=true; sender.getView().refresh(); } Quote Link to comment Share on other sites More sharing options...
mos Posted November 20, 2018 Author Share Posted November 20, 2018 14 hours ago, Sherzod said: Also, you can try this approach: function reconfigure(sender, store, columns, oldStore, oldColumns, eOpts) { columns[1].hidden=true; sender.getView().refresh(); } Hi, Will try this approach Quote Link to comment Share on other sites More sharing options...
mos Posted November 21, 2018 Author Share Posted November 21, 2018 17 hours ago, Sherzod said: Also, you can try this approach: function reconfigure(sender, store, columns, oldStore, oldColumns, eOpts) { columns[1].hidden=true; sender.getView().refresh(); } Hi Sherzod, It works! But as I change and change the data (via selecting from a list that reloads to grid), it wont work anymore? Quote Link to comment Share on other sites More sharing options...
Sherzod Posted November 21, 2018 Share Posted November 21, 2018 Can you make a simple testcase? 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.