Jump to content


Photo

TUnimDBListGrid Bind Custom Editor TUnimDBToggle - How ?

Editor

  • Please log in to reply
6 replies to this topic

#1 andyhill

andyhill

    Advanced Member

  • uniGUI Subscriber
  • PipPipPipPip
  • 200 posts
  • LocationMelbourne Australia

Posted 18 December 2017 - 04:42 AM

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[i].FieldName) = UpperCase('DNC') then begin
        TAccessListGrid(DBListGrid).Columns[i].Visible:= True;
        TAccessListGrid(DBListGrid).Columns[i].Width:= 80;
        TAccessListGrid(DBListGrid).Columns[i].Editor:= DNCToggle;
        us:= TAccessListGrid(DBListGrid).Columns[i].Title;
        us.Caption:= 'DNC';
        us.Alignment:= TAlignment(taLeftJustify);
        TAccessListGrid(DBListGrid).Columns[i].Title:= us;
        TAccessListGrid(DBListGrid).Columns[i].Sortable:= True;
        TAccessListGrid(DBListGrid).Columns[i].Alignment:= taLeftJustify; 
      end;
...
 

  • 0

Andy


#2 andyhill

andyhill

    Advanced Member

  • uniGUI Subscriber
  • PipPipPipPip
  • 200 posts
  • LocationMelbourne Australia

Posted 29 December 2017 - 04:18 AM

Farshad, Please advise.


  • 0

Andy


#3 andyhill

andyhill

    Advanced Member

  • uniGUI Subscriber
  • PipPipPipPip
  • 200 posts
  • LocationMelbourne Australia

Posted 30 December 2017 - 09:17 PM

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[i].rdonly=true;
        columns[i].align = 'center';
        columns[i].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;
*)

  • 0

Andy


#4 andyhill

andyhill

    Advanced Member

  • uniGUI Subscriber
  • PipPipPipPip
  • 200 posts
  • LocationMelbourne Australia

Posted 01 January 2018 - 03:27 AM

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.


  • 0

Andy


#5 Nigel602

Nigel602

    Active Member

  • uniGUI Subscriber
  • PipPipPip
  • 54 posts

Posted 06 January 2018 - 12:48 AM

+1 

 

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

 

Andy, did you manage to get this working? 


  • 0

#6 andyhill

andyhill

    Advanced Member

  • uniGUI Subscriber
  • PipPipPipPip
  • 200 posts
  • LocationMelbourne Australia

Posted 09 January 2018 - 12:45 AM

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

  • 0

Andy


#7 Delphi Developer

Delphi Developer

    Advanced Member

  • Moderators
  • 3885 posts

Posted 09 January 2018 - 05:34 AM

Hi Andy,

 

We will try to give you a solution.

 

Best regards,


  • 0





Also tagged with one or more of these keywords: Editor

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users