Page 1 of 1

Get data for field in selected record of table view

Posted: 2020-08-13 06:01
by David Soul
I am using AppGini Helper to add a link to each record in table view of “Players”

Code: Select all

 jQuery(function () {
 var tv = new AppGiniTableView();
 var href = "hooks/global-search.php?search=";
 tv.addLink(href, "flash", "global search");

});
I would like to add the data from the “name” field of the selected record in “Players” (after search= )but don’t know how to go about that; any assistance will be greatly appreciated.

Re: Get data for field in selected record of table view

Posted: 2020-08-13 08:48
by jsetzer

Code: Select all

jQuery(function () {

    var tv = new AppGiniTableView();
    var href = "hooks/global-search.php?search=";
    tv.addLink(href, "flash", "global search");

    let cn = "name"; // <-------------------YOUR column name here
    let tn = AppGini.currentTableName();
    jQuery("tr[data-id]").each((i, e) => {
        let value = jQuery(e).find("td." + tn + "-" + cn).text();
        jQuery(e).find("td:eq(0) > .btn-group > a[href]").each((i, e) => {
            let a = jQuery(e); a.attr("href", a.attr("href") + value);
        });
    });

});
This should work for the use case you have described. I have tested this in one of my tables with column name serialnumber.

chrome_LpHsfd0xxi.png
chrome_LpHsfd0xxi.png (20.51 KiB) Viewed 2857 times
chrome_eRsaN2MYa9.png
chrome_eRsaN2MYa9.png (2.66 KiB) Viewed 2857 times

Regards,
Jan

Re: Get data for field in selected record of table view

Posted: 2020-08-13 21:04
by David Soul
Success!

Once again a big thank you Jan!

The site I am putting together for a Canadian Charity (Hall of Fame/museum/archive) would be nowhere near as fit for task, nor near as user friendly, without your AppGini Helper and the “above and beyond” time you spend helping the entire AppGini community here.

Certainly - as a “non-coder” - I wouldn’t be able to do this work without APPGini, the tools In your product, and the work you and the rest of the “AppGini Super Hero” members so graciously give.

Re: Get data for field in selected record of table view

Posted: 2020-08-16 19:13
by jsetzer
Thank you, David!