How can I use php library functions in datatables? I am sharing the controller function.

How can I use php library functions in datatables? I am sharing the controller function.

susmitaduttasusmitadutta Posts: 2Questions: 1Answers: 0
edited June 2022 in Free community support
$columns = array(switchlang('sidebar_marketsum_countname'), switchlang('mng_com_location_name'), switchlang('mng_com_location_address'), switchlang('network_myprofile_city'), switchlang('city_code'), switchlang('acid_exporter_identification_number'), switchlang('business_vat_tax_id_no'),switchlang('bank_details'),switchlang('export_activedeals_addedon'), switchlang('settingsharedealdata_action'));

            $userData['user_data'] = "[

            {'data' : 'country_name'},
            {'data' : 'tcl_factory_name',
            'render': function(data, type, full) {
                if (full.tcl_is_central_office== '1' ) {
                    return full.tcl_factory_name+' '+'['+'HQ'+']';
                    } else {
                        return full.tcl_factory_name;
                    }
                }

                },
                {'data' : 'tcl_factory_address'},
                {'data' : 'tcl_factory_city_name'},
                {'data' : 'city_code'},
                {'data' : 'tcl_registration_number'},
                {'data' : 'tcl_business_vat_tax_id_no'},
                {'data':'bank_name',
                  'render':function(data,type,full){
                    return full.bank_name;
                  }

                },
                {'data' : 'created',
                render  :   function(data, type, full){
                    if(full.created != '') {
                        return moment(full.created).format('DD/MM/YYYY HH:MM:SS');
                        }  else {
                            return 'N/A';
                        }
                    }
                    },
                    {'data' : 'active',
                    render : function(data, type, full){
                        let markhq_text = 'Mark as HQ';
                        let hq_flag = full.tcl_is_central_office;
                        if (hq_flag == '1') {
                            markhq_text = 'Unmark';
                        }   
                        return '<div class=\"dropdown show\"><a class=\"btn btn-secondary dropdown-toggle\" href=\"#\" role=\"button\" id=\"dropdownMenuLink\" data-toggle=\"dropdown\" aria-haspopup=\"true\" aria-expanded=\"false\"><i class=\"fs-14 fa fa-bars\"></i></a><div class=\"dropdown-menu dropdown-menu-right\" aria-labelledby=\"dropdownMenuLink\"><a class=\"dropdown-item edit_btn timberEditBtnCls\" href=\"#\">" . switchlang('network_myprofile_edit') . "</a><a class=\"dropdown-item delete_btn timberDeleteBtnCls\" href=\"#\">" . switchlang('settinproduct_delete') . "</a><a class=\"dropdown-item hq_btn timberHqBtnCls\" href=\"#\">'+markhq_text+'</a></div></div>'
                    }
                }
            ]";

Edited by Allan - Syntax highlighting. Details on how to highlight code using markdown can be found in this guide.

Answers

  • allanallan Posts: 63,535Questions: 1Answers: 10,475 Site admin

    How can I use php library functions in datatables?

    You can't - DataTables is a Javascript library.

    What is it you are trying to do?

    Allan

  • susmitaduttasusmitadutta Posts: 2Questions: 1Answers: 0

    I want to decrypt the column value.
    render':function(data,type,full){
    return full.bank_name;

  • colincolin Posts: 15,240Questions: 1Answers: 2,599

    We're happy to take a look, but as per the forum rules, please link to a test case - a test case that replicates the issue will ensure you'll get a quick and accurate response. Information on how to create a test case (if you aren't able to link to the page you are working on) is available here.

    Cheers,

    Colin

Sign In or Register to comment.