This topic is locked

Determine column clicked for grid row AJAX snippet

8/3/2019 3:30:06 AM
PHPRunner General questions
A
alang author

On the Pages stage there is a click actions button next to the List page settings. I would like to define a grid row AJAX snippet (common to all columns/fields in the row) but need to know which column was clicked to pass as a parameter to the snippet code. Is there anyway for me to determine this in the code?
Background: I have up to 20 columns in the table displaying the same kind of data. I could replicate the function for each column (rather than trying to use the (grid row) but it seems like it would be very inefficient:
eg.
ajaxfn1:

var col="C01"

callpop(col,row)
ajaxfn2:

var col="C02"

callpop(col,row)
etc...

Admin 8/3/2019

If you use a grid row click event you cannot find the column that was clicked on. It is a row-level event.

A
alang author 8/5/2019



If you use a grid row click event you cannot find the column that was clicked on. It is a row-level event.


I thought that might be the case - so I have to create 20 different snippets - 1 for each column then.
Where do you suggest the best place would be to store a common function?

Admin 8/5/2019

Store it in an external PHP file. Then you can plug it in using the technique explained in this article:

https://xlinesoft.com/phprunner/docs/how_to_add_external_files.htm

A
alang author 8/6/2019

Thanks for your help Sergey. Something for the future suggestion list I guess. In this case, having the column number/name as a parameter would have been really useful - it is a bit tedious creating a separate function for each column even it is only a 1-liner <img src='https://asprunner.com/forums/file.php?topicimage=1&fieldname=reply&id=88429&image=1&table=forumreplies' class='bbc_emoticon' alt=':)' />
Great work on the program BTW - PHPRunner continues to be awesome!

A
alang author 8/12/2019

One more issue I found is that after editing the HTML page as described in the article, any change done in the designer is NOT effective until Editor page is Reset and the change re-applied. I discovered this after trying to make the table unresponsive (uncheck the Responsive checkbox). Bit of a trap that can cause some frustration <img src='https://asprunner.com/forums/file.php?topicimage=1&fieldname=reply&id=88474&image=1&table=forumreplies' class='bbc_emoticon' alt=':)' /> I guess it makes sense, but it might be useful to have some indication on the Designer tab that changes will not be applied while custom changes to the editor template are in place.
A better way to do this would be a code snippet in the designer but I suspect this is not possible at the moment?

W
wpl 8/12/2019

Alan,
maybe you could use this:
Get ID of TD on click of table
as a starting point to grab the content of the attribute "data-field" (i.e. the fieldname) of the clicked column in "JavaScript OnLoad" and pass it to the "click row event" via proxy (proxy.fieldname) to use it in your AJAX function like so:



ajaxfn:

var col=proxy.fieldname

callpop(col,row)


Regards

A
alang author 8/12/2019



Alan,
maybe you could use this:
Get ID of TD on click of table
as a starting point to grab the content of the attribute "data-field" (i.e. the fieldname) of the clicked column in "JavaScript OnLoad" and pass it to the "click row event" via proxy (proxy.fieldname) to use it in your AJAX function like so:



ajaxfn:

var col=proxy.fieldname

callpop(col,row)


Regards


Looks interesting - thanks for that. Definitely a better way to go using the "click row event" if possible in my view.

W
wpl 8/12/2019

it would be nice if you could keep us informed about any progress you are making.



Looks interesting - thanks for that. Definitely a better way to go using the "click row event" if possible in my view.