mos Posted December 4, 2017 Share Posted December 4, 2017 I have a number of questions: Is there a way of preventing the user from resizing the column below a minimum column width value so that the column is always visible? Is it possible to drag and drop columns to change the ordering of the columns in the grid? How can rows be sorted in ascending/descending order based on the column that is clicked? I have seen sorting code based on the VCL stringgrid which uses the Rows property and a temporary TStringList to perform the exchanging of the rows however the uniGUI stringgrid does not have this property. Quote Link to comment Share on other sites More sharing options...
mos Posted December 8, 2017 Author Share Posted December 8, 2017 Just bumping this. Also I have another question: 4. How can I update the UniCellAttribs of a cell without using OnDrawCell event? e.g. I have a timer which runs and I want to update a particular Cell background color based on a certain condition. Quote Link to comment Share on other sites More sharing options...
Sherzod Posted December 8, 2017 Share Posted December 8, 2017 Hi, We will check, For 2, 3: maybe you need to use uniDBGrid Quote Link to comment Share on other sites More sharing options...
mos Posted December 13, 2017 Author Share Posted December 13, 2017 Bumping this one again. Any further updates on the items above specifically item 1 and 4? Quote Link to comment Share on other sites More sharing options...
Sherzod Posted December 13, 2017 Share Posted December 13, 2017 Hi, Bumping this one again. Any further updates on the items above specifically item 1 and 4? Do you use FixedCols ?! Quote Link to comment Share on other sites More sharing options...
mos Posted December 13, 2017 Author Share Posted December 13, 2017 Hi Delphi Developer, FixedCols is set to 0. Quote Link to comment Share on other sites More sharing options...
Sherzod Posted December 13, 2017 Share Posted December 13, 2017 Ok, I will try to analyze Quote Link to comment Share on other sites More sharing options...
Sherzod Posted December 13, 2017 Share Posted December 13, 2017 Hi, 4. How can I update the UniCellAttribs of a cell without using OnDrawCell event? e.g. I have a timer which runs and I want to update a particular Cell background color based on a certain condition. One possible solution, Can you try to use this approach?: For example for Row=0 (tr:nth(1)) and Column=0 (td:nth(1)) nth(n) (1 based) procedure TMainForm.UniButton1Click(Sender: TObject); begin with UniStringGrid1.JSInterface do begin JSCode(#1'.normalGrid.getView().el.select("tr:nth(1) td:nth(1)").elements[0].style["background-color"]="green";'); JSCode(#1'.normalGrid.getView().el.select("tr:nth(1) td:nth(1)").elements[0].style["color"]="white";'); end; end; Best regards, Quote Link to comment Share on other sites More sharing options...
mos Posted December 13, 2017 Author Share Posted December 13, 2017 Hi Delphi Developer, I seem to be getting some sort of Ajax error. See attached screenshot. Quote Link to comment Share on other sites More sharing options...
Sherzod Posted December 14, 2017 Share Posted December 14, 2017 Hi, Which build are you using? Quote Link to comment Share on other sites More sharing options...
mos Posted December 14, 2017 Author Share Posted December 14, 2017 Hi Delphi Developer, Build 1413. Quote Link to comment Share on other sites More sharing options...
Sherzod Posted December 14, 2017 Share Posted December 14, 2017 Hi, Hi Delphi Developer, I seem to be getting some sort of Ajax error. See attached screenshot. If it's not difficult for you, please make a test case Quote Link to comment Share on other sites More sharing options...
mos Posted December 14, 2017 Author Share Posted December 14, 2017 Hi Delphi Developer, Attached is a test case that generates the Ajax error. StringGrid.zip Quote Link to comment Share on other sites More sharing options...
Sherzod Posted December 14, 2017 Share Posted December 14, 2017 Ok, Try this: with UniStringGrid1.JSInterface do begin JSCode('var view, me='#1'; if(me.normalGrid) {view=me.normalGrid.getView()}else{view=me.getView()}; view.el.select("tr:nth(1) td:nth(1)").elements[0].style["background-color"]="green";'); JSCode('var view, me='#1'; if(me.normalGrid) {view=me.normalGrid.getView()}else{view=me.getView()}; view.el.select("tr:nth(1) td:nth(1)").elements[0].style["color"]="white";'); end; Quote Link to comment Share on other sites More sharing options...
mos Posted December 14, 2017 Author Share Posted December 14, 2017 Hi Delphi Developer, If I put some code to set the cell text before the two JSCode lines the cell colors appear correctly. with UniStringGrid1.JSInterface do begin UniStringGrid1.Cells[0,0] := 'test'; JSCode('var view, me='#1'; if(me.normalGrid) {view=me.normalGrid.getView()}else{view=me.getView()}; view.el.select("tr:nth(1) td:nth(1)").elements[0].style["background-color"]="green";'); JSCode('var view, me='#1'; if(me.normalGrid) {view=me.normalGrid.getView()}else{view=me.getView()}; view.el.select("tr:nth(1) td:nth(1)").elements[0].style["color"]="white";'); end; If I put the line after the two JSCode lines the cells don't have the colors applied. Is there a reason why the colors are not applied if the UniStringGrid1.Cells[0,0] := 'test'; is after the two JSCode lines? Quote Link to comment Share on other sites More sharing options...
mos Posted December 15, 2017 Author Share Posted December 15, 2017 Hi Delphi Developer, I tried to create a TUniStringGrid in code and then used the JSCode lines you gave me but I get an Ajax Error. I have attached a sample test case. StringGrid2.zip Quote Link to comment Share on other sites More sharing options...
Sherzod Posted December 15, 2017 Share Posted December 15, 2017 Hi, Ok I will check it Quote Link to comment Share on other sites More sharing options...
mos Posted December 18, 2017 Author Share Posted December 18, 2017 Hi Delphi Developer, Any update? Quote Link to comment Share on other sites More sharing options...
mos Posted December 22, 2017 Author Share Posted December 22, 2017 Hi Delphi Developer, Still waiting for some sort of update. Quote Link to comment Share on other sites More sharing options...
Sherzod Posted December 22, 2017 Share Posted December 22, 2017 Hi, Sorry for the delay, I will try to find a workaround Best regards, Quote Link to comment Share on other sites More sharing options...
Sherzod Posted December 25, 2017 Share Posted December 25, 2017 Hi, One possible solution, try: 1. UniStringGrid1 -> ClientEvents -> UniEvents -> function beforeInit: function beforeInit(sender, config) { var me = sender; me.createStylesArray = function(rows) { var arr = []; for (var i = 0; i < rows; i++) { arr[i] = []; } return arr; }; } 2. UniStringGrid1 -> ClientEvents -> ExtEvents -> function reconfigure: function reconfigure(sender, store, columns, oldStore, oldColumns, eOpts) { var me = sender; for (i = me.fxCols; i < columns.length; i++) { columns[i].renderer = function(value, meta, record) { if (me.rc && me.rc[meta.rowIndex][meta.columnIndex + me.fxCols]) { meta.style = me.rc[meta.rowIndex][meta.columnIndex + me.fxCols]; } return value; } }; } 3. MainForm -> OnReady: procedure TMainForm.UniFormReady(Sender: TObject); begin UniStringGrid1.JSInterface.JSCode('var me='#1'; me.rc=me.createStylesArray(me.store.count());'); end; How to use, for example: procedure TMainForm.UniFormReady(Sender: TObject); begin UniStringGrid1.JSInterface.JSCode('var me='#1'; me.rc=me.createStylesArray(me.store.count());'); UniStringGrid1.JSInterface.JSCode(#1'.rc[2][2]="background-color:green; color:white";'#1'.view.refresh();'); end; procedure TMainForm.UniButton1Click(Sender: TObject); begin UniStringGrid1.JSInterface.JSCode(#1'.rc[1][1]="background-color:green; color:white";'#1'.view.refresh();'); end; procedure TMainForm.UniButton2Click(Sender: TObject); begin UniStringGrid1.JSInterface.JSCode(#1'.rc[1][1]="";'#1'.view.refresh();'); end; Best regards, Quote Link to comment Share on other sites More sharing options...
mos Posted January 30, 2018 Author Share Posted January 30, 2018 Hi Delphi Developer, Is it possible to set up a column of cells (e.g. column 1) in a string grid so that when you click in a cell a TUniColorPalette is displayed underneath the cell, and once the user selects a color the cell background is set to this color? I would also need to know what color was selected so I can store it in the cells object. The other question I have is how can I display a drop down combobox with some options in a cell and get the option that is selected so I can store it in a cell object? Quote Link to comment Share on other sites More sharing options...
mos Posted February 7, 2018 Author Share Posted February 7, 2018 Hi Delphi Developer, Any help with the above two items would be appreciated. Quote Link to comment Share on other sites More sharing options...
Sherzod Posted February 7, 2018 Share Posted February 7, 2018 Hi, Ok, I will try to analyze your requests, Which build are you using? Quote Link to comment Share on other sites More sharing options...
mos Posted February 7, 2018 Author Share Posted February 7, 2018 Hi Delphi Developer, Build 1413. 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.