Jump to content

uniDbGrid Tray Add Objects (buttons)


andyhill

Recommended Posts

Hi

 

Project from here: http://3msoft.net/mhmd/dbgridtray.rar

 

We will turn paging tool bar from:

 

0.png

 

To this:

 

1.png

 

What we did:

  • We hide the First page, Last page, Refresh buttons
  • We add a label to show how many selected rows
  • we add two buttons aligned to the right

 

We will use two images and we will put them inside a folder 'images':

 

2.png

 

when we want to hide buttons we will need there index...

 

3.png

 

4.png

 

5.png

 

6.png

 

7.png

  • Like 1
Link to comment
Share on other sites

Hi,

 

With my uniDBGrid I want to add two uniDatePickers (not time) to the paging bar next to the Refresh button and capture the date change so I can fetch new data - please advise.

 

Can you try this approach ?!:

function pagingBar.boxready(sender, width, height, eOpts)
{
    this.add([

        '-',

        {
            xtype: "datefield",
            fieldLabel: 'Start Date',
            labelWidth: "60px",
            format: 'm/d/Y',
            width: 200,
            listeners: {
                change: function(el, v) {
                    alert(v)
                }
            }
        },

        '-',

        {
            xtype: "datefield",
            fieldLabel: 'End Date',
            labelWidth: "60px",
            format: 'm/d/Y',
            width: 200,
            listeners: {
                change: function(el, v) {
                    alert(v)
                }
            }
        }
    ]);
}

Best regards,

Link to comment
Share on other sites

Thank You :).

 

Moving forward:-

 

1) I need to seed them with today's date

 

2) I want to fire a delphi procedure when the date is changed (not counting seeding)

 

3) When midnight is crossed I would need to re-seed them with the new date

Link to comment
Share on other sites

1) I need to seed them with today's date

{
    xtype: "datefield",
    fieldLabel: 'Start Date',
    labelWidth: "60px",
    format: 'm/d/Y',
    value: new Date(), // <----------
    width: 200,
    listeners: {
        change: function(el, v) {
            alert(v)
        }
    }
}
Link to comment
Share on other sites

2) I want to fire a delphi procedure when the date is changed (not counting seeding)

 

Well, try this:

 

1.

{
    xtype: "datefield",
    fieldLabel: 'Start Date',
    labelWidth: "60px",
    format: 'm/d/Y',
    value: new Date(),
    width: 200,
    listeners: {
        change: function(el, v) {
            ajaxRequest(sender, "_dateChange", ["dtIndx=0", "val=" + Ext.Date.format(v, "d/m/Y")]) // <------
        }
    }
}

2.

procedure TMainForm.UniDBGrid1AjaxEvent(Sender: TComponent; EventName: string;
  Params: TUniStrings);
var
  newDate : TDate;
  Fmt: TFormatSettings;
begin
  if EventName = '_dateChange' then
  begin
    Fmt.ShortDateFormat:='dd/mm/yyyy';
    Fmt.DateSeparator  :='/';

    newDate := StrToDate(Params.Values['val'], Fmt);
    //ShowMessage(DateToStr(newDate));
  end;
end;
Link to comment
Share on other sites

Hi,

 

Could you show me how to achieve 3) above - thanks

 

If I understand you correctly, first of all you must determine this time most likely in the UniTimer I guess, and after setting the date, to disable the timer and re-enable after a certain time...

 

How can you do this?

Link to comment
Share on other sites

For example:

 

1.

uses ... DateUtils

2. UniTimer:

 

Interval = 60000

OnTimer ->

procedure TMainForm.UniTimer1Timer(Sender: TObject);
begin
  if CompareTime(Time, EncodeTime(0,0,0,0)) >= 1 then
  begin
    UniTimer1.Interval := ? // or other logic
    UniSession.AddJS('Ext.getCmp("startDateID").setValue(new Date());');
  end
  ...
  ...
end;

3.

{
    xtype: "datefield",
    fieldLabel: 'Start Date',
    labelWidth: "60px",
    format: 'm/d/Y',
    value: new Date(),
    id: "startDateID",  //<--------------
    width: 200,
    listeners: {
        change: function(el, v) {
            ajaxRequest(sender, "_dateChange", ["dtIndx=0", "val=" + Ext.Date.format(v, "d/m/Y")])
        }
    }
}
Link to comment
Share on other sites

  • 11 months later...
On 10/12/2017 at 10:59 PM, Sherzod said:

Hi,

 

For a start you can do this:


function pagingBar.boxready(sender, width, height, eOpts)
{
    this.add({
        text: "Test",
        handler: function() {
            alert("test")
        }
    });
}

 

On 10/18/2017 at 11:26 PM, andyhill said:

Thank you Farsad, if we every meet up I owe you a beer.

 

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