MarcoRu Posted October 11, 2013 Share Posted October 11, 2013 Hi all, I'm trying to get all visible columns at runtime (in web mode), but if I try to do it using the property Visible of a column, it doesn't work. If I click on the column title to hide or show a column, as shown in picture attached. the column is hidden, but the property Visible of that colum remain true. How can I retrieve all visible columns at a given time? The code I write is this, but with the property Visible doesn't work: procedure TmailsFrame.getVisibleColumns(var slColumns: TStringList);var iCount: Integer;begin try slColumns.Clear; for iCount := 0 to UniDBGrid1.Columns.Count - 1 do begin if (UniDBGrid1.Columns.Items[iCount].Visible = true) then slColumns.Add(UniDBGrid1.Columns.Items[iCount].Title.Caption); end; except on e: Exception do ShowMessage(e.Message); end;end; Quote Link to comment Share on other sites More sharing options...
Sherzod Posted October 11, 2013 Share Posted October 11, 2013 Hi MarcoRu. Try this: uses ... UniGUIApplication ... procedure TMainForm.UniButton1Click(Sender: TObject); begin UniSession.AddJS('var strList = ""; Ext.each('+UniDBGrid1.JSName+'.columns, function(col, index) {if (!col.hidden){if (strList === ""){strList = col.text}{strList = strList + "," + col.text}}}); ajaxRequest ('+UniButton1.JSName+',''getVisibleList'', [''List=''+strList]);'); end; procedure TMainForm.UniButton1AjaxEvent(Sender: TComponent; EventName: string; Params: TStrings); begin if (EventName = 'getVisibleList') Then begin //Params.Values['List'] - Returns a string separated by commas ... ShowMessage(Params.Values['List']); end; end; Sincerely ... Quote Link to comment Share on other sites More sharing options...
rullomare Posted October 11, 2013 Share Posted October 11, 2013 Hi, I had the same problem. I do not know if you can help : Sample Code .... Procedure TFXXX.XReadColumnsHidden; Var Xread : String ; begin Xread := 'Xreadvisible' ; unisession.addjs('var cols=new Array(' +inttostr( grid.Columns.Count)+ ');' + 'for (i=0;i<cols.length;i++){'+ 'cols=' + grid.Jsname +'.columns.hidden;}'+ 'var str=cols.toString();' + 'ajaxRequest(' + grid.jsname + ',' + '''' + Xread + '''' + ' , ["ofs="+str])'); end; procedure TFXXX.gridAjaxEvent(Sender: TComponent; EventName: string; Params: TStrings); StrVisible : String ; Ts : Tstrings ; begin if SameText(Eventname,'XreadVisble') then begin StrVisible := Params.Values['ofs']; // Code Sample Ts := Tstringlist.Create ; Ts.Delimiter := ',' ; Ts.DelimitedText := StrVisible ; Code Sample for I := 0 to grid.Columns.count - 1 do begin // Your code .................. end; ts.free ; // Code Sample end ; end; regards 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.