gm3h Posted December 2, 2011 Share Posted December 2, 2011 I know that one day, Farshad will add any available field editor/viewer to the grid. But, for the moment it is not available. What I do is simple, setting the 'renderer' properties of the field. Here's what I do to make any Boolean field to be showed/rendered as CheckBox in the grid. 1. Set the Column Tag to 1, this is to mark that this column will be 'rendered' as CheckBox. 2. In the OnShow event of the form that contain the grid, put this code: procedure TMainForm.UniFormShow(Sender: TObject); var st,xcolheader:string; i,j:integer; begin xcolheader:=''; j:=UniDBGrid1.Columns.Count; for i := 0 to j-1 do begin If UniDBGrid1.Columns[i].Tag=1 then begin xcolheader:=xcolheader+'colModel.columns[i].header=="'+UniDBGrid1.Columns[i].Title.Caption+'"||'; end; end; xcolheader:=copy(xcolheader,1,Length(xcolheader)-2); st:='OnReconfigure=function OnReconfigure(sender, store, colModel) {'+ 'for(i=1;i<colModel.columns.length;i++) {'+ 'if ('+xcolheader+') {'+ ' colModel.columns[i].renderer=function(v, p, record){'+ ' p.css += " x-grid3-check-col-td";'+ ' return ''<div class="x-grid3-check-col''+(v == ''1''?''-on'':'''')+''"> </div>'';}'+ '}}}'; UniDBGrid1.ClientEvents.ExtEvents.Add(st); end; I'm using Firebird, so the boolean value is 0 or 1.... if you are using other DB, then you can modify the v == ''1'' above to any value that you need for 'true' condition.... Hope this can help somebody that need it. Cheers.... 1 Link to comment Share on other sites More sharing options...
dynamo Posted January 11, 2012 Share Posted January 11, 2012 Thanks.It works on WEB application. But doesn't work checked/unchecked clicking this field . Link to comment Share on other sites More sharing options...
gm3h Posted January 13, 2012 Author Share Posted January 13, 2012 Thanks.It works on WEB application. But doesn't work checked/unchecked clicking this field . well, as I've said before, this is only for temporary solution with older version of uniGUI. Since there's a new DBGrid Editor, I think you don't need my tips above. Link to comment Share on other sites More sharing options...
Recommended Posts
Please sign in to comment
You will be able to leave a comment after signing in
Sign In Now