Jump to content

Left top corner in UniDBGrid


artem_niko

Recommended Posts

Hello!

I have question about top left corner in UniDBGrid. I mean place in this top left corner:

image.png.4ffd9748585dc91ccb346d0fff2feada.png

As default, if use Options of UniDBGrid, we can show or hide this FilterClearButton:

image.png.fd56d4ddf32aa68cd393cc909641ffd7.png

As default, this button clearing fileds where put filter.

I want replace this action on anouther action. For example, I want refresh data in UniDBGrid.

This is my two question:

1. Is it possible replace icon of this button (FilterClearButton) on icon from UniImageList?

2. Is it possible change size this button?

Link to comment
Share on other sites

3 hours ago, Артем said:

How do this? Is it exist in demo files? 

Try this approach for now:

1. UniDBGrid.ClientEvents.UniEvents -> 

function beforeInit(sender, config) 
{
    var me = sender;
    me.setClearBtnSt = function(faIconName, btnWidth, hint) {
        var col = me.columnManager.columns[0];
        var colCF = col.items.getAt(0);
        if (colCF) {
            colCF.addCls("x-fa fa-"+faIconName+" fa-2x");
            colCF.setWidth(btnWidth);
            colCF.btnWrap.setStyle('display', 'none');
            colCF.setStyle('text-align', 'center');
            colCF.setStyle('height', '100%');
            colCF.setStyle('line-height', btnWidth + "px");
            col.setWidth(btnWidth);
            col.titleEl.setStyle('display', 'none');
            if (hint != ""){
                colCF.setTooltip(hint);
            }
        }
    }
}

2. Usage

procedure TMainForm.UniFormReady(Sender: TObject);
//var
  //fa: TUniIconFontFamily;
begin
  //https://fontawesome.com/v4.7.0/icons/
  with UniDBGrid1 do
    if dgFilterClearButton in Options then // setClearBtnSt(faIconName, btnWidth, hint)
      //JSInterface.JSCall('setClearBtnSt', [UniNativeImageList1.GetIconCls(0, fa), 40, 'Refresh...']);
      JSInterface.JSCall('setClearBtnSt', ['refresh', 40, 'Refresh...']);
end;

 

  • Like 2
Link to comment
Share on other sites

1 hour ago, Sherzod said:

Try this approach for now:

1. UniDBGrid.ClientEvents.UniEvents -> 


function beforeInit(sender, config) 
{
    var me = sender;
    me.setClearBtnSt = function(faIconName, btnWidth, hint) {
        var col = me.columnManager.columns[0];
        var colCF = col.items.getAt(0);
        if (colCF) {
            colCF.addCls("x-fa fa-"+faIconName+" fa-2x");
            colCF.setWidth(btnWidth);
            colCF.btnWrap.setStyle('display', 'none');
            colCF.setStyle('text-align', 'center');
            colCF.setStyle('height', '100%');
            colCF.setStyle('line-height', btnWidth + "px");
            col.setWidth(btnWidth);
            col.titleEl.setStyle('display', 'none');
            if (hint != ""){
                colCF.setTooltip(hint);
            }
        }
    }
}

2. Usage


procedure TMainForm.UniFormReady(Sender: TObject);
//var
  //fa: TUniIconFontFamily;
begin
  //https://fontawesome.com/v4.7.0/icons/
  with UniDBGrid1 do
    if dgFilterClearButton in Options then // setClearBtnSt(faIconName, btnWidth, hint)
      //JSInterface.JSCall('setClearBtnSt', [UniNativeImageList1.GetIconCls(0, fa), 40, 'Refresh...']);
      JSInterface.JSCall('setClearBtnSt', ['refresh', 40, 'Refresh...']);
end;

 

Excellent! Working:

image.png.6ffa824ffa9426dc1b2b8094748af146.png

Very big thank's! :)

  • Like 1
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...