Jump to content
uniGUI Discussion Forums
andyhill

TUnimDBListGrid Bind Custom Editor TUnimDBToggle - How ?

Recommended Posts

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;
...
 

Share this post


Link to post
Share on other sites

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;
*)

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites

+1 

 

I would also like to know how to implement this, if possible. 

 

Andy, did you manage to get this working? 

Share this post


Link to post
Share on other sites

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];
      }
    }
  );
}

Share this post


Link to post
Share on other sites

Hi Andy,

 

We will try to give you a solution.

 

Best regards,

Share this post


Link to post
Share on other sites

×