Jump to content

Set enabled a uniTimer from client side


msegura
 Share

Recommended Posts

Hi msegura. 
 
This approach is suitable?
 
1. 
procedure TMainForm.UniTimer1EventHandler(Sender: TComponent; EventName: string;
  Params: TStrings);
begin
  if (not (Sender as TUniTimer).Enabled) and (EventName = '_start') then begin
    (Sender as TUniTimer).Enabled := True;
  end;
end;

2. Set enabled:

procedure TMainForm.UniButton1Click(Sender: TObject);
begin  
  UniSession.AddJS('ajaxRequest(' + UniTimer1.JSName + ', ''_start'', []);');
end;
or just:
procedure TMainForm.UniButton1Click(Sender: TObject);
begin 
  UniTimer1.Enabled := True
end;
Sincerely.
Link to comment
Share on other sites

Hi and thank you very much for answering so quickly.

 

It's a good approach but unfortunately it doesn't work for my case.

 

I have a form where there is a dbgrid. What I need is to update a combobox when a column is clicked to be ordered.

 

I change the tabindex property of the combobox on the event OnColumnSort of the grid but the combo is not updated. That's why I thougth to use a timer as I read on some post of this forum.

 

I do not wan to have the timer triggering events constantly so when the combobox is updated I disable it. The problem is that I can't enable the timer again.

 

Any ideas?

 

Thank you very much.

Link to comment
Share on other sites

Use latest version of unigui

if you change unicombobox.itemindex := value , combobox will be updated.

 

another  solution :

 

Create a table with the content of the combobox. (in database or in  memory)

Put a UniDBLookupComboBox instead a combobox, ,  set listsource to a dataset to this table,  set listfield and keyfield,

when you click in the dbgrid and OnColumnSort event is generated, set UniDBLookupComboBox.keyvalue to your columname or value.

Link to comment
Share on other sites

I've already prepared a proyect to show you the problem. This project is based on the Column Sort demo.
 
You can also find attached a screen shot of the real project. I need that combo because it is important for users used to the old interface and it is neccesary they have a soft transitions between the old interface and the new one.
 
Thank you very much for your help.

 

post-1378-0-90048300-1402682718_thumb.png

ColumnSort.zip

Link to comment
Share on other sites

Hi msegura!

Sorry, to be honest, the problem is not very clear to me ...

I do not see two-way communication with the combobox.

If I understand correctly, try to include this code:

procedure TMainForm.UniComboBox1Change(Sender: TObject);
begin  
  UniSession.AddJS(UniDBGrid1.JSName + '.getStore().sort({ property: ''' + IntToStr(UniComboBox1.ItemIndex) + ''', direction : ''ASC''});');
end;

If I do not understand correctly, please again clarify the problem, I'll be glad to help you!


Sincerely.

Link to comment
Share on other sites

Thank you very much for your answer again.

 

The piece of code in your answer is very useful for me, thank you. But It does not solve my real problem which is in the opposite way. 

 

What a I need is to change the value of the combox when the grid is ordered by pressing on the column name. You can see the code for UniDBGrid1ColumnSort where I change the value of ItemIndex of ComboBox (  UniComboBox1.ItemIndex := Column.Index;) but visually it is not changed.

 

 

Thank you very much!!!

 



procedure TMainForm.UniDBGrid1ColumnSort(Column: TUniDBGridColumn;
  Direction: Boolean);
begin
  UniMainModule.SortColumn(Column.FieldName, Direction);


// Here is my problem. I change the ItemIndex but visually
// the combo does not change and it always shows the same value

  UniComboBox1.ItemIndex := Column.Index;

end;

Link to comment
Share on other sites

Oh my God, I'm depressed!! It does not work for me neither FF 20.0.1 nor Chrome 35.0.

 

The sample project I sent is compiled with Rad Studio XE4 and Unigui 0.95.0.1041

 

Any ideas what's happening or how could I work arround to solve it?

 

 

Thanks in advanced.

Link to comment
Share on other sites

And so you can change the value of combobox, try

 

UniDBGrid1 -> ClientEvents -> ExtEvents -> add function sortchange:

function sortchange(ct, column, direction, eOpts)
{
  Ext.getCmp(MainForm.UniComboBox1.id).select(Ext.getCmp(MainForm.UniComboBox1.id).getStore().getAt(column.dataIndex));
}

Best regards.

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.

 Share

×
×
  • Create New...