andyhill Posted December 18, 2017 Share Posted December 18, 2017 I have a TUnimDBListGrid (DBListGrid) and I want to bind a custom editor TUnimDBToggle (DNCToggle) which is present on a hidden panel to a boolean field 'DNC' - please show me how - thanks. ... if UpperCase(TAccessListGrid(DBListGrid).Columns.FieldName) = UpperCase('DNC') then begin TAccessListGrid(DBListGrid).Columns.Visible:= True; TAccessListGrid(DBListGrid).Columns.Width:= 80; TAccessListGrid(DBListGrid).Columns.Editor:= DNCToggle; us:= TAccessListGrid(DBListGrid).Columns.Title; us.Caption:= 'DNC'; us.Alignment:= TAlignment(taLeftJustify); TAccessListGrid(DBListGrid).Columns.Title:= us; TAccessListGrid(DBListGrid).Columns.Sortable:= True; TAccessListGrid(DBListGrid).Columns.Alignment:= taLeftJustify; end; ... Link to comment Share on other sites More sharing options...
andyhill Posted December 29, 2017 Author Share Posted December 29, 2017 Farshad, Please advise. Link to comment Share on other sites More sharing options...
andyhill Posted December 30, 2017 Author Share Posted December 30, 2017 Please show me how to use CheckBox in TUnimDBListGrid. The code below is from General forum for TUniStringGrid, can someone please show me how to do this for TUnimDBListGrid - thanks. (* //1. UniStringGrid1 -> ClientEvents -> UniEvents -> function beforeInit: function beforeInit(sender, config) { var me=sender; me._check=function(v, r, c){ ajaxRequest(me, '_check', ['value='+v, 'rowIndex='+r, 'columnIndex='+(c+me.fxCols)]); } } //2. UniStringGrid1 -> ClientEvents -> ExtEvents -> function reconfigure: function reconfigure(sender, store, columns, oldStore, oldColumns, eOpts) { for (i = sender.fxCols; i < columns.length; i++) { columns.rdonly=true; columns.align = 'center'; columns.renderer = function(value, a) { return "<input type='checkbox'" + ((value == '1') ? "checked='checked'" : "") + " onclick='"+sender.nm+"._check(+this.checked, "+a.rowIndex+", "+a.columnIndex+")'>"; }; } } //3. UniStringGrid1 -> OnAjaxEvent: procedure TMainForm.UniStringGrid1AjaxEvent(Sender: TComponent; EventName: string; Params: TUniStrings); begin if EventName='_check' then (Sender as TUniStringGrid).Cells[strToInt(Params.Values['columnIndex']), StrToInt(Params.Values['rowIndex'])] := Params.Values['value'] end; *) Link to comment Share on other sites More sharing options...
andyhill Posted January 1, 2018 Author Share Posted January 1, 2018 Mohammad, I have asked for Farshad to comment but no help as yet. Would you be so kind and show me how to bind a CheckBox/Toggle to a TUnimDBListGrid column (2nd column) - thanks. Link to comment Share on other sites More sharing options...
Wicket Posted January 6, 2018 Share Posted January 6, 2018 +1 I would also like to know how to implement this, if possible. Andy, did you manage to get this working? Link to comment Share on other sites More sharing options...
andyhill Posted January 9, 2018 Author Share Posted January 9, 2018 bleh602, I would appreciate a name when communicating. I have assumed that the ability to bind editors to Mobile Grid Components is not possible based on a lack of response from those in the know (I would have appreciated an answer though). If I am correct I believe this must be addressed. A comment given to me privately not that long ago was that "uniGui mobile is very green and has a very small user base" of which I cannot confirm or deny other than observations on the forum where responses on mobile postings are very slow. In the mean time (via experimentation) I have created a new html table Ext.XTemplate and decided in the end to use an image instead of a checkbox as it looked better (I am only displaying data in read only mode). I am happy for suggestions for a better way. function beforeInit(sender, config) { config.itemTpl = new Ext.XTemplate ( '<table>'+ '<tr>'+ '<td width="118px" style="text-align:left;">{[this.getNumber(values)]}</td>'+ '<td width="76px" style="text-align:left;">{[this.getDNC(values)]}</td>'+ '<td width="150px" style="text-align:left;">{[this.getLanguage(values)]}</td>'+ '</tr>'+ '</table>', { getNumber: function(values) { return values[0]; } }, { getDNC: function(values) { if(values[1] == true) return '<img src="images/dnc.png" width="24px" height="24px" align="middle" style="margin:auto;"/>'; else return '</>'; } }, { getLanguage: function(values) { return values[2]; } } ); } Link to comment Share on other sites More sharing options...
Sherzod Posted January 9, 2018 Share Posted January 9, 2018 Hi Andy, We will try to give you a solution. Best regards, Link to comment Share on other sites More sharing options...
Recommended Posts