Quantcast
Channel: Recent Discussions — DataTables forums
Viewing all 81971 articles
Browse latest View live

Need the proper syntax to set a value of a field.

$
0
0

Need the proper syntax to set a value of a field by calculated the values of 2 0tger fields in my server side PHP.

Here is what I have tried.

        Field::inst('xxxx.Fld1),
        Field::inst('xxxx.Fld2),

        Field::inst('xxxx.Fld3)
               ->setValue( Field:: Fld1 * Field:: Fld2 )



Multi-select drop down to date picker

$
0
0

Happy Morning one and all,

Following is the code that is used to create multi-select filter under each column, how can I bring a datepicker in one of the date columns. Please refer Exhibit.

select: true,
lengthChange: false,
initComplete: function () {
    this.api().columns().every( function () {
        var column = this;
        var select = $('<select><option value=""></option></select>')
            .appendTo( $(column.footer()).empty() )
            .on( 'change', function () {
                var val = $.fn.dataTable.util.escapeRegex(
                    $(this).val()
                );

                column
                    .search( val ? '^'+val+'$' : '', true, false )
                    .draw();
            } );

                column.data().unique().sort().each( function ( d, j ) {

                if(column.search() === '^'+d+'$'){

                select.append( '<option value="'+d+'" selected="selected">'+d+'</option>' )
                } else {
                select.append( '<option value="'+d+'">'+d+'</option>' )
                }
                } );

    } );
},

Exhibit

column.search() is not filtering my table

$
0
0

Can you please check what did I missed in my datatable. I've created a simple search but it's not filtering.

<input type="text" id="txtserial" name="txtSerial" class="form-control" />

Here's my javascript:

       var dtmyJob = $('#myJob').DataTable({
            "aLengthMenu": [[10, 25, 50, -1], [10, 25, 50, "All"]],
            iDisplayLength: -1,
            sScrollY: "40vh",
            bScrollInfinite: true, //this property disables pagination
            "scrollCollapse": true,
            "paging": false,
            "bInfo": false,
            "bFilter": false,
            "bSort": false
        });

        $("#txtserial").on('keyup', function () {
            dtmyJob.columns(2).search(this.value).draw();
            alert(dtmyJob);
        });

How to change the text of a collection button or change the text of one of the collectioned button

$
0
0

Hi all,

I'm a junior web developper and for the need of my company we use a DT in our new web-application
I use collection them to filter data with hidden colunms and hidden input which contains strings and now I want to change the text of one of my collection button to show the user which filter is enable so I know that we can use this.text() to change the text of simple buttons whitout collection system and now I'm looking for a way to apply this system to a collection button or if you folks have a better idea.

Thanks.

(Sorry for my approximate english)

collection

Putting together different data from different tables

$
0
0

That the situation:
I have three different table, i must arrange an array with data from this table...

Here a part of Json to better explain

"data": [
    {
      "DT_RowId": "row_150",
      "ol": {
        "id": "150",
        "ol": "0",
        "fase": "8",
        "centrale": "roma",
        "Data_Inizio": "2017-11-17",
        "Data_Fine": "2017-11-17",
        "cliente_id": "3",
        "fatturato": "1",
        "Materiali_id": "",
        "costi_materiali": null,
        "impiegati_id": null,
        "Time_Stamp": "2017-12-06 10:49:51"
      },
      "clienti": {
        "nome": "FastWeb"
      },
      "materiali": [
        {
          "id": "7",
          "codice": "F-LCLC01-DX-B"
        }
      ],
      "movimenti": [
        {
          "id": "355",
          "quantita": "1",
          "materiale_id": "7"
        }

The last part: I have an array in "movimenti" and another in materiali, i "movimenti" i need to use "codice" and not "materiale_id.

Here the queries:

->join(
        Mjoin::inst( 'materiali' )
            ->link( 'ol.id', 'vardisp.olid' )
            ->link( 'materiali.id', 'vardisp.matid' )
            ->fields(
                Field::inst( 'id' )
                    ->validator( 'Validate::required' )
                    ->options( Options::inst()
                        ->table( 'materiali' )
                        ->value( 'id' )
                        ->label( 'codice' )
                    ),

                Field::inst( 'codice' )

            )
    )





   ->join(
        Mjoin::inst( 'movimenti' )

            ->link( 'movimenti.ad_ol_id', 'ol.id' )

            ->fields(
                Field::inst( 'id' )
                    ->validator( 'Validate::required' )
                    ->options( Options::inst()
                        ->table( 'movimenti' )
                        ->value( 'id' )
                        ->label( array ('quantita', 'materiale_id' ))

                    ),

                Field::inst( 'quantita' ),
                Field::inst( 'materiale_id' )


            )
    )

and here how I use the data on JS


{data: "movimenti", render: function ( data, type, full ) { return $.map( data, function ( d, i ) { return d.materiale_id +' '+ d.quantita; } ).join( ', ' ); }}

any ideas?
tx a lot

How do I append row data to a generated link

$
0
0

Hi,

So I've created a table using server side processing and I need to append data from the book number row to the link in the extra column i've created.

So for example, if the books number is 5 for that row, the link needs to be href="page/book/delete-book.php?5"

Here's my code:

$('#bookTable').DataTable({
"processing": true,
"serverSide": true,
"ajax":{
url :'book-data.php',
type: "post",
error: function(){
$(".book-table-error").html("");
$("#bookTable").append('<tbody class="book-table-error"><tr><th colspan="3">No data found in the server</th>
</tr></tbody>');
}
},
"columnDefs": [{
"targets": -1,
"data": null,
"defaultContent": '<a href="page/book/delete-book.php?"><i style="color:red;" class="fa fa-fw fa-trash"></i>
</a>'
}]
});

My understanding is that I need a way to basically reference the data from my ajax request but I have no idea how

Any help would be much appreciated!

Fetch currently Logged-in user row from Data-table and show

$
0
0

Question: When the particular user logged-in using the Register Number. I want only the particular row to be fetched from all the table and shown in a block/page to the current user.

I think using search or filter code can do this.

How can i do this ?

Please find the Image attachment(Data table added using Feed).

Responsive, Ajax and Statesave

$
0
0

Hello,
Sorry for my English ...
To display the data of my Datatable, I use the AJAX, I also use the plugin Responsive, and during the display, this plugin executes 2 times the AJAX request to recover the data, how to prevent this second request (identical )?
And why, the statesave feature no longer works on paging when the Responsive plugin is present?
If you could help me, thank you very much.


Datatable Search/Filter code

$
0
0

This "data table" feature is awesome.

I want to know the code for Search ** and **filter.
Does anyone know.
Note: Easy for me to understand if its a ** PHP Code**

Fixedheader not working with multiple Datatable on single page

$
0
0

Hi , In my project I am using Datatable . Every page have three to four tables and I want fixed header for every table. As only current active or visible table's header will have fixed header

I had tried with static html table it is working but it is not working with dynamic json binding
**Current Issues **
1) After Datatable is binded the fixed header doesn't get applied , It get applied If I click on any event button
2) The last binded header is getting fixed for all the data table
3) Even the header is not getting properly aligned with table horizontal![] (img has been attached )
(https://datatables.net/forums/uploads/editor/xt/b4mf6q1bqmg4.png "")
scroll

** Here the code which I am using **
_
$('#tableID').dataTable({
fixedHeader: {
header: true
},
data: JSONDATA,
"aaSorting": [],
"columns": currentcolumns,
"columnDefs": currentcolumnsdef,
"destroy": true
});
$('#tableID').dataTable().fixedHeader.adjust();_

Audiot logging for editor.

$
0
0

Hey guys,

I need to add some sort of audit logging for create/delete and edit functions on the data-tables editor. Any examples and help
would be much appreciated.

I'm looking to dump data into an audit table on each action.. something really simple.. doesn't have to dump username or anything.. just data trail.. date+action+data_before+data_after

Example for an edit

[field: date] = {2017-01-10 : 19:05:23}
[field: action] = {edit}
[field: data_before] = {id=1, name="foo baarson", age=110, info="too old"}
[field: data_after] = {id=1, name="bar fooson", age=110, info="too old"}

Example for a create

[field: date] = {2017-01-10 : 19:05:23}
[field: action] = {create}
[field: data_before] = {}
[field: data_after] = {id=1, name="bar fooson", age=110, info="too old"}

Example for a delete

[field: date] = {2017-01-10 : 19:05:23}
[field: action] = {delete}
[field: data_before] = {id=1, name="foo baarson", age=110, info="too old"}
[field: data_after] = {}

This way you can write a recovery script to the side.. like an 'undelete' button.. or even have one inline in the table.

Datatable with no paging. Why?

$
0
0

I'm working with a set of "metrics" data that to requires dynamic creation of Datatables as the number o "metrics" tend to varies.
As I generate the Html code to include the tables, they are shown without any pagination (all the rows one after another, generating a huge table in my page). I'm using a Json response to generate the data, and here is the code:

$.getJSON($url+'?request=exdaily&id_cam='+$id_cam, function(json){
              $.each(json.data, function(key, value){
                $(".metrics-container").append(metricTable(key, value));
                $("#daiTable #"+key).DataTable({
                  "paging": true
                });
              });
            })
            .done(function(){
            });

the metricTable function:

function metricTable(mKey, mValue){
        var html;
        html +=
        '<div style="clear:both;" id="daiDiv">'+
          '<h3 class="daily tableTitle blue">'+mKey+'</h3>'+
          '<table id="daiTable '+mKey+'" border="0" class="table table-hover">'+
            '<thead>'+
              '<tr>'+
                '<th>DateCreated</th>'+
                '<th>Experience</th>'+
                '<th>Revenue</th>'+
              '</tr>'+
            '</thead>'+
            '<tbody>';

        $.each(mValue, function(key, value){
          html +=
          '<tr>'+
            '<td>'+value['DateCreated']+'</td>'+
            '<td>'+value['Experience']+'</td>'+
            '<td>'+value['Revenue']+'</td>'+
          '</tr>';
          });
          html += '</tbody>'+
          '</table>'+
          '<div id="dateSlider"></div>'+
          '<div>'+
            '<h4 class="revenue" style="display: inline-block;"></h4>'+
            '<p class="back2top blue">Back to Top</p>'+
          '</div>'+
        '</div>';

      return html;
}

Note: the $(".metrics-container") is a Div inside the Html body.
I will gladly give more details in order to solve this problem, thanks!

Populating with all contacts & cutomers.

$
0
0

I have a customers & contacts table. Both tables have unique field custID. contacts table have multiple contacts from one company

I am trying to get the following result

customers.custID | contacts.firstName | contacts.firstName

500              |  John              |   Paul

ie I need them in separate fields.

Is this possible in a MYSQL Query?

If so what is the syntax to use with the editor.

The idea is I can use responsive extension and show the company details and then have all the contacts show on expanding the row.

Or is there another approach?

Cheers

Steve Warby

TinyMCE working with editor inputs

$
0
0

I'm trying to get the TinyMCE plugin to work with the editor inputs. I just read that TinyMCE doesn't work with inputs and only block elements. I keep getting back the following error via my console which makes sense I suppose.

Could not initialize inline editor on invalid inline target element <input id=​"DTE_Field_item_desc" type=​"text">​

If it doesn't support input elements, what options do I have? Do I download another text editor like CK Editor?

Here is my code I am currently using

    editor.on( 'open', function ( e, type ) {
        tinymce.init({
            selector: '#DTE_Field_item_desc',
            inline: true
        });
    } );

How can I add a second table to a page?

$
0
0

I need to add a second table to a page, and this second table uses different data than the first. I'm attaching my current page. It reads data from a local JSON file. Can anyone explain to me briefly what I need to do, or point me to some documentation? Thanks.


Datatables print extensión. Block principal view

$
0
0

Hello first of all I want to congratulate you for your work, I have a little doubt. How can I block the main window after sending a print to chrome? I explain. When I use the print button everything works correctly and I open the print in another window. The problem is that I can change to the tab where the table is originally, press buttons and other actions. However, these are not done because they are waiting for the response from the print window. I hope you have explained me well

Reload all data send id and json

$
0
0

Hello,
I try to refresh the table to each click in which a parameter is sent, I honestly do not know how to do that process.

The following code does what I need but I'm not sure it's the right one.

      $('.rsel').click(function(e){
        $('#wlista').css('display','block');
        idexp = $(this).attr('id');
        $('#wlista').find('h2').text($($('figcaption span')[idexp]).text());

        if(table != null) {
          table.destroy();
        }

        table = $('#datatable').DataTable({
            "autoWidth": false,
            "order": [[ 0, "desc" ]],
            "processing": true,
            "ajax": {
              "url":"<?php echo base_url() ?>documentos/getDocExpAjax",
              "type": "POST",
              "data": {
                id_expediente: idexp
              },
            },
            "columns": [
              { "data": "id_documento" },
              { "data": "identificador" },
              { "data": "nombre_documento" },
              { "data": "productor" },
              { "data": "estado"},
              { "data": "accion"}
            ],
            "columnDefs": [
              {
                "targets" : [5],
                "visible" : ("<?php echo $this->session->userdata('codigo') ?>" == 'AD') ? true : false,
                "searchable" : ("<?php echo $this->session->userdata('codigo') ?>" == 'AD') ? true : false,
              }
            ],
            "language":
              {
                "url": "<?php echo base_url('vendors/datatables.net/i18n/Spanish.json') ?>"
              },
        });
      });

Initialize a single-column table with a plain array

$
0
0

I'd like to initialize a single-column table with a plain array.
Doing the following results in each row having the first letter of each array item (Of course, that's not what I need):

var dataArr = ["James", "Joe", "John"]
var table = $('#exampleTable').DataTable({
    data: dataArr,
  columns: [{title: "Name"}]
});

Now, doing the following works, but it would require me to wrap each item in an array of its own, which is undesirable:

var dataArr = [["James"], ["Joe"], ["John"]]
var table = $('#exampleTable').DataTable({
    data: dataArr,
  columns: [{title: "Name"}]
});

Is there some initialization option I can use to make the plain array work?

How to re-render the table after updating a cell so the table understands that there is a new value

$
0
0

Hi! I am a newbie to DataTables and I encountered with a huge (for me) problem that I just don't get how to solve. Here is my live demo https://codepen.io/Balzzac/pen/mpdGgL with questions in certain places .

Let me try to explain: i have a table (id='js_table') that gets data from AJAX call (in codepen - from variable dataSet). It has 2 columns: "Assigned" and "Name". When data comes I render the first column, replacing "yes"/"no" with circles for type==="display" and with"assigned"/"not assigned" for "else", so it looks nice and provide a user the opportunity via clicking on the circle to assign or unassign a person.

When clicking on the circle (js_assign_element), JS runs a function where it replaces classes (from green to red and vice versa) as well as changing data-attributes into "assigned" when the person wasn't assigned and "not assigned" when person was. But the table itself doesn't "understand/recognize" the change, so it sorts and filters the first column like no changes were made.

$(document).off('click', '.js_assign_element').on('click', '.js_assign_element', function (event) {
     event.preventDefault();
    event.stopPropagation();
    if ($(this).hasClass("__assigned")) {
        $(this).removeClass("__assigned").attr("data-search", "not assigned").attr("data-filter", "not assigned").attr("data-sort", "not assigned").attr("data-order", "not assigned")
    }
    else
    {
        $(this).addClass("__assigned").attr("data-search", "assigned").attr("data-filter", "assigned").attr("data-sort", "assigned").attr("data-order", "assigned")
    }

    // Tried Following:
    // $("#js_table").DataTable().draw() - doesn't work
    // $("#js_table").DataTable().rows().invalidate("dom").draw() - doesn't work
    // $("#js_table").DataTable().rows().invalidate().draw() - doesn't work either
})

Can you please look and help me with my question(s)? Thanks

How to search for values in a table that have a many to one relation with the table that is shown

$
0
0

I need to search for values in a table that have a many to one relationship with the main table that is show with datatables. How can I send this search information to the php server side script? I will collect the search information in a form but how can i send the form information with the ajax call that is use to update the datatables?

Viewing all 81971 articles
Browse latest View live


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>