Include an external variable in hyperlink of an column

Include an external variable in hyperlink of an column

radu.cruceanaradu.cruceana Posts: 5Questions: 0Answers: 0

Hello again,
I'm less than beginner in DataTables or dev in general :)

So, I use Laravel 5.4 and several DataTables which get their data with ajax requests and everything it's working super fine.


        lengthMenu: [[15, 25, 100, -1], [15,25, 100, "All"]],
        processing: true,
        serverSide: true,
        ajax: 'ajaxFurnizori',
        columns: [
            {data:'id',name:'id' , sClass: "hidden", "bSearchable": false },
            {data: 'furnizor', name: 'furnizor',
                "fnCreatedCell": function (nTd, sData, oData, iRow, iCol) {
                    $(nTd).html("<a href='introducereOferta?idFurnizor=" + + "'>" + oData.furnizor + "</a>")
            { data: 'tara', name: 'tara' },

HTML blade template:

@extends ('master')
    <div class="container">
        <div class="row">
            <div class="col-sm-12">

                <div class="tabelOferte" style ="width: 900px">
                    <table id = "tabelFurnizoriOferta" class="table table-responsive table-striped table-hover">
                        <thead >
                        <tr style="font-weight: bold" >
        {{--Hidden input Get idClient from previous GET--}}
        <input name="idClient" , id="IdClient" type="text" value = {{$idClient}} hidden>

PHP controller which respond to ajax request

    public function furnizori(Request $request)
        return  Datatables::of(DB::table('furnizori')->
                get([' as id','furnizori.denumire as furnizor','tari.denumire as tara']))->make(true);

What I want, is to send the hidden input idClient in DataTables hyperlink, to concatenate somehow in the link something like "idClient" = $("#idClient)

Is this possible?
I know that one possible solution is to return view from the controller and include in it a static DataTable (with data prepared by the controller).


  • radu.cruceanaradu.cruceana Posts: 5Questions: 0Answers: 0

    Someone, please help :)

  • allanallan Posts: 42,648Questions: 1Answers: 5,492 Site admin + '&idClient=' + $("#idClient).val()

    should do it I think. i.e. just get the value and add it to the url, unless I'm misunderstanding something?


Sign In or Register to comment.