Watch, Follow, &
Connect with Us

For forums, blogs and more please visit our
Developer Tools Community.


Welcome, Guest
Guest Settings
Help

Thread: How can I access onclick event from HTML listview item in delphi


This question is answered. Helpful answers available: 2. Correct answers available: 1.


Permlink Replies: 2 - Last Post: Mar 22, 2017 1:35 PM Last Post By: Eitan Arbel
Buzu Dan

Posts: 8
Registered: 5/17/09
How can I access onclick event from HTML listview item in delphi  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Mar 21, 2017 7:39 AM
I am using template and JQuery mobile 1.4.5

I create the HTML template and inside a listview that is populated in delphi form from a dataset...

Var Onclick : string
OnClick := Format('onclick="return alert(''%s'');"',[CDS.FieldByName('Employee_Number').AsString]);
 
<ul data-role="listview" data-inset="True">
  <li> 
      Format('<a href="#" %s>',[OnClick]) 
      <h2>  CDS.FieldByName('Employee_Full_Name').AsString  </h2>
      <p>  CDS.FieldByName('Employee_ID').AsString  </p>
      <p class="ui-li-aside">  CDS.FieldByName('Employee_Number').AsString  </p> ...etc
</a>
</li>

this is working very ok. I need to access this event to can do something else - load a new page, execute some other actions. I prefere to have a method in delphi
to execute for onclick event in list view item.
Somebody know how to do that ?
How can register a delphi OnClik method to javascript?

Thanks!
Dan

Edited by: Buzu Dan on Mar 21, 2017 7:39 AM

Edited by: Buzu Dan on Mar 21, 2017 7:40 AM

Edited by: Buzu Dan on Mar 21, 2017 7:40 AM

Edited by: Buzu Dan on Mar 21, 2017 7:41 AM

Edited by: Buzu Dan on Mar 21, 2017 7:43 AM
Buzu Dan

Posts: 8
Registered: 5/17/09
Re: How can I access onclick event from HTML listview item in delphi  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Mar 22, 2017 3:57 AM   in response to: Buzu Dan in response to: Buzu Dan
I find how to do it and maybe uis usefully for others too:

1.First of all use templates - html and IWTemplateProcessorHTML
example at: [Jquesry example with intraweb|https://www.youtube.com/watch?v=75DnldrcJNU&t=1043s]

Note: I do not us ethe dbgrid at all - create directly the listview and populate thru CDS

2. In create form add
WebApplication.RegisterCallBack('OnListItemClick', iwListViewClick);


3. in html file - <head>
<script>
      function onListViewItemClick(event){
          executeAjaxEvent("&itemtext="+event, null,"OnListItemClick",false, null, false);
         };
</script>


4. where render listview add:

OnABtn1Click :=  Format('OnClick = "onListViewItemClick(%s);"',['Value']);
...
Format('<a href="#" data-role="button" data-icon="arrow-u" data-iconpos="notext" %s>A1</a>',[OnABtn1Click]);
...


done!

Edited by: Buzu Dan on Mar 22, 2017 3:58 AM

changing dataset will automaticity (thru tag) update list view.

Edited by: Buzu Dan on Mar 22, 2017 1:34 PM
Eitan Arbel

Posts: 508
Registered: 2/24/13
Re: How can I access onclick event from HTML listview item in delphi  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Mar 22, 2017 4:11 AM   in response to: Buzu Dan in response to: Buzu Dan
Thank you for the info !
i think i may need that :)
Legend
Helpful Answer (5 pts)
Correct Answer (10 pts)

Server Response from: ETNAJIVE02