Page 1 of 2

how to add a button inside list item ??

PostPosted: 20 Dec 2017 10:20
by fateh78
how to add a button inside list item ??
what is the best way to do that ?
i inherited a new class from TIWCGJQSortableList and changed GetHtmlTag procedure to produce a button inside the item
now how to assign onclick event to the button ??

Re: how to add a button inside list item ??

PostPosted: 20 Dec 2017 17:58
by Jorge Sousa
Hi Fateh

If you have CGDevTools source code look for examples of CGRegisterCallBack (and CGUnregisterCallback)

Re: how to add a button inside list item ??

PostPosted: 21 Dec 2017 01:21
by fateh78
how can identify the clicked item ?

Re: how to add a button inside list item ??

PostPosted: 21 Dec 2017 11:14
by Jorge Sousa
Send us what you have by email and we will tell you, it's very hard to answer these kind of questions without seeing any code, i hope you understand

Re: how to add a button inside list item ??

PostPosted: 21 Dec 2017 20:02
by fateh78
Dear Sousa

find attached demo

thanks in advance

note : the attached project contains demonstration for other 2 cases we talk about before, and i'll send in their posts respectively

Re: how to add a button inside list item ??

PostPosted: 22 Dec 2017 12:28
by Jorge Sousa
Hi Fateh

Sorry, but there was a lot of information i had to give you in order for you to make your own custom components for Intraweb / CGDevTools.

We don't have the time or the resources to do this.

Re: how to add a button inside list item ??

PostPosted: 22 Dec 2017 14:40
by fateh78
so please help in just 2 questions :
1- how to assign javascript to the button onclick event
2- how to identify itemindex for the clicked button (how to add itemindex to event params)

i think it would be a good idea if added 2 buttons (remove, edit) to the component

i'll appreciate your help highly

Re: how to add a button inside list item ??

PostPosted: 22 Dec 2017 15:37
by Jorge Sousa
Hello

I will try my best, but its not easy

1- how to assign javascript to the button onclick event


https://api.jquery.com/click/

you have to use this form ("#id"),click(....

2- how to identify itemindex for the clicked button (how to add itemindex to event params)


This is even more complicated, this uses hidden inputs, you have to follow our code with examples. the method we use are

procedure GetInputControlNames(ANames: TStringList); override;

for rendering

and

procedure SetValueByName(const AName, AValue: string); override;

for server handling

and also, you have to use

.click on the li tags, in order to set these hidden inputs using the javascript function CGSetHiddenInputVal

this will mark an hidden input as dirty to be sent to the server


BTW: I notice in your MWSortableList.pas code this

With Result.Contents.AddTag('ol') do begin
AddStringParam('id', JQHTMLName);

this is wrong it will render repeated inputs, using at least someting like AddStringParam('id', 'ol_' + JQHTMLName);

Re: how to add a button inside list item ??

PostPosted: 22 Dec 2017 15:37
by Jorge Sousa
Hello

I will try my best, but its not easy

1- how to assign javascript to the button onclick event


https://api.jquery.com/click/

you have to use this form ("#id"),click(....

2- how to identify itemindex for the clicked button (how to add itemindex to event params)


This is even more complicated, this uses hidden inputs, you have to follow our code with examples. the method we use are

procedure GetInputControlNames(ANames: TStringList); override;

for rendering

and

procedure SetValueByName(const AName, AValue: string); override;

for server handling

and also, you have to use

.click on the li tags, in order to set these hidden inputs using the javascript function CGSetHiddenInputVal

this will mark an hidden input as dirty to be sent to the server

Re: how to add a button inside list item ??

PostPosted: 24 Dec 2017 00:51
by fateh78
i make it working, but i am not sure if this is the correct way :?:
it would be nice if you review this updated demo

also 2 notes :
1- i needed to call : Self.AjaxReRender(False, False);
to update the list, is there a function to update the list without rerender ?! :idea:
2- the list items expand out of containing panel
is there a way to show scrollbars when list expand ?! :idea:

best regards dear Sousa :ugeek: