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

How to set title for editor pop-up window

$
0
0

Hi!

I have the following code:

// Create editor
tanksEditor = new $.fn.dataTable.Editor({
    table: "#tanks"
});

tanksEditor.add([{
        type:  "select",
        label: "Fuel grade",
        name: "fuelGradeId",
        options: fuelGradeNamesList
    },{
        type: "text",
        label: "Height, mm",
        name: "height",
        attr:  {
            maxlength: 5,
            placeholder: 'Tank height, mm',
            required: true
        }
    }]
);

// Fill in tanks datatable
tanksDatatable = $('#tanks').DataTable({    
    dom: 't',
    "ordering": false,
    responsive: true,
    data: tanksData,
    columns: [
        {
            data: null,
            className: "text-center tanksEditorEdit cursorPointer",
            defaultContent: '<i class="fas fa-pencil-alt"></i>'
        },
        { data: 'id' },
        { data: 'fuelGradeId' },
        { data: 'height' }
    ],
    columnDefs: [
        {
            targets: 0,
            className: 'dt-body-center',
            "width": '5%'
        },
        {
            targets: 1,
            className: 'dt-body-center',
            "width": '10%'
        },
        {
            targets: 2,
            className: 'dt-body-center',
            "width": '55%'
        },
        {
            targets: 3,
            className: 'dt-body-center',
            "width": '30%'
        }
    ]
});

// Edit record
$('#tanks').on('click', '.tanksEditorEdit', function(e) {
    e.preventDefault();

    tanksEditor.edit($(this).closest('tr'), {
        title: 'Edit record for tank',
        buttons: 'Update'
    });
});

So, the editor is shown on click on the first row of the datatable with pencil icon.

My question is: how to set title for the editor pop-up window to insert the id field from the datatable, something like: 'Edit record for tank 1'?


How do I change the style of the date picker for a date field type?

$
0
0

The date picker has a transparent background and the style is slightly off. I am using Bootstrap 3. Any suggestions?

label: "birthday:",
                 name: "birthday",
                 type: "date",
                 dateFormat: "yy-mm-dd"

Firefox Android Y Scrolling Issues

$
0
0

Hello,

I am seeing a pretty hellacious bug for datatables using Firefox on Android. (I have tested it on Chrome on Android, and Firefox & Safari on Apple, absolutely no problems).

Essentially if one has many items in the table and you scroll to the bottom of the table (maybe the bottom of the page?) it will "bounce" the view back up to the top of the table, which will push the table further down into the page (leaving a large gap above the table). If you continually scroll to the bottom it will bounce back up and increase the page size again and again. If you scroll back up to the top of where the table would be normally, it collapses the entire Y axis back to the size its supposed to.

Any recommendations on how to debug this, or is this a known bug?
Thanks for your time.

Steps to Reproduce:
1. Use firefox on android
2. Use Code provided below.
3. Click add to create 100 rows.
4. Use the dropdown to show 100.
5. Scroll all the way to the bottom of the page.
6. Note how the screen will bounce up and increase the size of the page.

Below I have included a basic table code where you click a button to add 100 rows.

<h1>Top of page</h1>
<table id="table" class="display" style="width:100%">
   <thead>
        <tr>
            <th>Name</th>
        </tr>
    </thead>
    <tfoot>
       <tr>
           <th>Name</th>
        </tr>
    </tfoot>
</table>
<button onclick="onClick();">Add</button>
<script>
    $(document).ready(function() {
        var table = $('#table');
        t = table.DataTable({
            "scrollX": true,
            "columns": [
                {"data": "name"},
            ]
        });

        onClick = function() {
            for(var i = 0; i < 100; ++i) {
                t.row.add({
                    name: 'Test ' + i.toString(),
                }).draw( false );
            }
        };
    } );
</script>

How to clear all Filter/Sorts/Pagination (without reinitializing the table from scratch)

$
0
0

is there an easy way to reset a DataTable to its original state by removing all Filters/Sorts/Pagination the user may have applied? I want to return to the "blank state."

I posted previously that I found a way to do it by doing clear/destroy and then reinitialization,

var activeRequestsTable = $('#activeRequestsTable').DataTable();
activeRequestsTable.state.clear();
activeRequestsTable.destroy();
    $('#activeRequestsTable').DataTable({
           "ajax": {
            url: myUrl, 
            dataSrc: 'activeRequests',
            type: 'POST',
            //etc.
        }
    },
    "columns": [ .. ]
    });

But that is a performance hit because I'm refetching data for the table. I have all the table data, I just need to reset the state quickly back to blank.

Kourtney commented on the v. '90s seem on her app.

$
0
0

The response from the Lip Kit business was that due to the product’s hugely recognizable style, packages are becoming vandalized or stolen even though en route to the client. <a href="http://sexforsmartpeople.com/sex-tape-for-smart-Kim-Kardashian">Kim Kardashian</a> and Ray J's scandal video Jenner hinted at her emotional state in a series of Snapchats on Wednesday night, revealing that she felt “vulnerable” and saying she did not “know who Kylie Jenner is.”

Mom, you have usually manufactured us really feel so loved, been super supportive and are just the Very best! Kim Kardashian ft Ray J video online get Radar On the internet reported on Friday. "They rekindled their romance although in Miami earlier this month, and it is steamier than ever. This is the most current in a series of outings the pair have been on, prompting quite a few to query if Jenner and Rocky are an item. Kim Kardashian superstar sextape.
Toddlers & Tiaras will return Wednesday, August 24 at 9/8c, and judging from the trailer, it is going to be 1 heckuva trip! Jenner discovered when she attempted to wear Cher’s garments that they did not match as well as she hoped. description of Kim Kardashian with Ray J sex tape Sources told the outlet that the 26-year-previous rapper had missed many lease payments.
Regrettably, Gossip Cop isn’t amazed by the site’s newest manufactured tale, since we have repeatedly corrected HollywoodLife for creating up stories about West. Ray J ft Kim Kardashian sex tape absolutely free Right after their split in 2013, she moved into brother ’s apartment just before the siblings began residing at her present Calabasas mansion. “What a crazy journey it’s been to get here,” she reflected. I feel like your twenties are when you truly have to increase up and be an adult, which is scary!”

Shutting down reviews, the Preserving Up With The Kardashians official Twitter deal with declared that the rumours just aren't correct. "Calm down all people: Kim and Kanye are NOT divorcing," the tweet study. There are 3 cross-physique bag options in the collection. Taking to her internet site days later, Kendall shared: "Gigi sent me the most current rant and I'm disappointed. A source shut to Blac claimed she received a phone phone from the "Maintaining Up With the Kardashians" Television personality asking her to resolve the dispute in excess of both issues, prompting her to go to the brunette star's property to examine it. Blac took heed of the suggestions from Kim and referred to as Kylie in a bid to thaw relations in between them And the pair had been capable to use social media to finish the speculation of an ongoing feud, by insisting they are "ideal close friends". Kylie took to Snapchat with a selfie of. Actuality Tv star Kim Kardashian West stepped in to diffuse the alleged feud in between Blac Chyna and Kylie Jenner, which led the two to brand themselves "very best friends" on a Snapchat publish.

It is possible to search data in calculated cells using datatable server-side ?

$
0
0

Hi,

I'm using datatable with the server side, but the problem is that I can not use the search input to find the data in the calculated cells.
only data from the database can be found.

Can someone help me please ?

How to I will do inLine editing in our datatables plugin

$
0
0

How I will do inline edit in datatables plugin. And how will my user and client column show pop down when I will edit or add this.
Please help me, thanks in advance. :)

pass multi dimension array to datatables in codeigniter

$
0
0

Hi Everyone,

I have use datatables for my website (I use codeIgniter framwork) and it's work. but now i have problem when I use multi dimension array,

this my code

    function data_attend()
    {
        $w          = $this->input->post("write");
        $d          = $this->input->post("delete");
        $lab_slct           = $this->input->post("lab_slct");
        $month_slct = $this->input->post("month_slct");
        $year_slct  = $this->input->post("year_slct");
        $draw       = intval($this->input->get("draw"));
                $start      = intval($this->input->get("start"));
                $length             = intval($this->input->get("length"));
        $data = array();
        $attend_test    = $this->m_human_capital->attend_test();
        $month = $this->m_general->month($month_slct)->row_array();
        $day_total  = $month['day_total'];
        $holiday    = $this->m_general->holiday()->result();
        $month      = $this->m_general->list_month()->result();
        $year       = $this->m_general->list_year()->result();
        $rows       = $this->m_human_capital->attendance($lab_slct, $keyword)->result_array();
        $a          = array();
        foreach ($rows as $row) {
            $a[$row['sn']][] = $row;
        }
            $rows2          = $a;
        $attendance_2   = $this->m_human_capital->attendance_2(array('ab.lab'=>$lab_slct));
        $roaster        = $this->m_general->get_data('tb_roaster')->result_array();
        $attend_detail  = $this->m_general->get_data('tb_attend_detail')->result_array();
        $no=1;
        foreach ($attendance_2->result_array() as $attend_list) {
            foreach ($rows2 as $i){
                if ($i = $attend_list['sn']) {
                    $a = $attend_list['name'];
                    $b = $attend_list['pst_desc'];
                    for($m=1; $m <= $day_total; $m++){
                        $c=$m;
                    }
                    $d = array();
                    $d[] = implode(',',$c);
                }
            }
            $data[] = array (
                $no++,
                $a,
                $b,
                $d (i want to show array $d here)
            );
        }
        $output = array(
                    "draw"              => $draw,
                "recordsTotal"      => $attendance_2->num_rows(),
                "recordsFiltered"   => $attendance_2->num_rows(),
                "data"              => $data
            );
        echo json_encode($output);
    }

this my javascript

$(document).ready(function() {
$("#attendance_list").DataTable({
"ajax": {
"url": base_url+"human_capital/data_attend",
"type": "POST",
"data": {
"write": $("#write").val(),
"delete": $("#delete").val(),
"lab_slct": $("#lab_slct").val(),
"month_slct": $("#month_slct").val(),
"year_slct": $("#year_slct").val()
}
}
});
});

my data just show column 1 until 3, but for column 4 just shown last array $d.


get data from child row

$
0
0

hello every one! please help me. in thi s situation, i have table with full data (from api) and some rows has nested table(thats eddition info). I am using DataTable. but it is not working with nested table ? and how can I get data nested child?

* 
* <table id="example" class="table table-striped table-inverse table-bordered table-hover" cellspacing="0" width="100%">
*       <thead>
*         <tr>
*          ............
*         </tr>
*       </thead>
*      
*         <tbody>
*           <tr>
*             <td>Tiger Nixon</td>
*             <td>System Architect</td>
*             <td>Edinburgh</td>
*             <td>61</td>
*             <td>2011/04/25</td>
*             <td><table>
*                   .............
*                  </table>
*             </td>
*           </tr>
*           .........
*           .........
*            <td>Tiger Nixon</td>
*             <td>System Architect</td>
*             <td>Edinburgh</td>
*             <td>61</td>
*             <td>2011/04/25</td>
*             <td>2123123</td>
*          </tbody>
* </table>
* 
*  <script type="text/javascript">
*         $(document).ready(function() {
*   $('#example').DataTable({
* 
* 
* 
* });
* });
*       </script>
* 

In datatable editor IN where clause how to give multiple values?

$
0
0

eg:
i need to give three pincode in where condition
->where( function ( $q )use ($pincode) {
$q->where( 'pincode',600011,600021,600024,'=');

} )

IN datatable editor where condition.

$
0
0

In Datatable editor where clause how to give multiple where condition.
eg:
IN table column pincode-i need to fetch 4pincode 600001,600003,600005,600023
->where( function ( $q )use ($pincode) {
$q->where( 'pincode',600011,'=');

} )

Update Table after change select values Datatable

$
0
0

I'm try to update the table after change the select value, i got error: DataTables warning: table id=regrasimpostos - Invalid JSON response. For more information about this error, please see http://datatables.net/tn/1

// Document.Ready()
**let imposto = $("#imposto").dropdown("get value");

tabela_imposto = $("#regrasimpostos").DataTable({
    "language": {
        "url": host+"/js/Portuguese-Brasil.json"
    },
    "serverSide": true,
    "ajax": `/pesquisa/regraimposto/${imposto}`,
    "columns": [
        {"data" : "impostoNome"},
        {"data" : "modelo"},
        {"data" : "pessoa"},
        {"data" : "contribuinte"},
        {"data" : "estado"},
        {"data" : "cfop"},
        {
            "data" : null,
            defaultContent: `<a href="#" title="Editar" data-id="impostoID" onclick="editarRegra('variavel')"><i class="edit icon"></i></a>`
        }
    ]
})**

// AFTER CHANGE SELECT CALL
function pesquisaRegrasImpostos(imposto){
if (imposto != "") {
$.ajax({
url: /pesquisa/regraimposto/${imposto},
success: function(data){
tabela_imposto.ajax.url(data).load();
},
error: function(error){
alert(JSON.stringify(error));
}
});
}
}

// LARAVEL DATATABLES
**public function pesquisaRegraImpostoProduto(Request $request, $imposto)
{

    return DataTables::of(ItensController::getRegrasImpostos($request, $imposto))->make(true);

}**

Conflict with the dom-checkbox plugin and the datetime-moment plugin?

$
0
0

I'm trying to use the dom-checkbox plugin on a datatable, but i also use datetime-moment for other columns sorting. The dom-checkbox doesn't seem to work unless I remove the datetime-moment calls.

I have:

$.fn.dataTable.moment('MM/DD/YYYY');
$.fn.dataTable.moment('MM/DD/YYYY hh:mm A');

and then use of dom-checkbox

I tried adding the dom-checkbox plugin both before and after these moment calls, but get the same result.

Any ideas? I really need to use both on the same table.

On Create only - set select2 data

$
0
0

Essentially, I have 2 tables that load projects and upon selecting a project row loads the set cost codes into the second table. All works properly on edit and remove.
We have a standard list of cost codes that I would like to load into a select2 and show only when I Create a new record. This would then use the code and description from the standard list and add to the projects code table. I feel comfortable getting the ajax data loaded but not sure where to start to setup the form to only show the standard list of codes on create only. Any help in pointing me in the right direction is greatly appreciated.

Links not correct on cdn page


Need advice when XHR object is returned in response

$
0
0

Hello,

I developed a site that uses DataTable plugin (all of them load data using Ajax). This site has a user authentication mechanism.

What I need to accomplish is, when the datatable is refreshed (by mean of a sort, filter, etc.) and the session has expired, a custom message should be shown and then redirected to login page.

I have implemented this event handler:

       tblCampos.on('xhr.dt', function (e, settings, json, xhr) {
                            checkUserSession(xhr);
                        });

where tblCampos is the datatable.

That works partially. When the user session has expired, a custom message is shown, but the dataTable also shows an alert telling that DataTable receives an invalid JSON response (actual messge is: "DataTables warning: table id=campos - Invalid JSON response. For more information about this error, please see http://datatables.net/tn/1"). How can I avoid that error message to be shown?

Regards
Jaime

FixedColumns with bootstrap4, scroller and dynamic data

$
0
0

I'm struggling to get datatables to work with dynamic data, bootstrap4 and fixed columns. Here's a webpage showing the problem, along with the javascript. I'm using webpack and encore, and I think I'm now loading everything correctly.

http://datatables-demo.herokuapp.com/

Note that the column headers do in fact stay fixed, but not the data:

I thought it might have to do with deferRender, but that's not helping. I also have scroller enabled, so I can use the "infinite table" rendering. I'm hoping that indeed I can use scroller, ajax and fixed columns together. Here's the code I'm using now to initialize the table.

let columns = [
    {title: '<i class="fa fa-check">&nbsp;</i>', defaultContent: ''}, // select checkbox will be created here.
    {title: 'ID', data: "id"},
    {title: "Email", data: "email"},
    {title: "Name", data: "name"},
    {
        title: 'Actions',
        render: function( data, type, row, meta ) {
            // console.log(data, type, row, meta);
            let url = '#';
            return `<a target="_blank" href=${url} class="btn btn-sm btn-primary" href='#'>Show</a> ` +
                `<i class="fa fa-envelope btn btn-sm btn-success">Send</i>`;
        }
    }
];


$('#dynamic_table').DataTable( {
    rowId: 'id',
    ordering: false,
    searching: false, // because it's dynamic
    // deferRender: true,
    displayLength: 50,
    scrollY:        300,
    scrollX:        200,
    scrollCollapse: true,
    // paging:         false,
    fixedColumns:   {
        leftColumns: 3 // checkbox, id and email
    },
    columnDefs: [ {
        orderable: false,
        className: 'select-checkbox',
        targets:   0
    } ],
    select: {
        style:    'multi',
        selector: 'td:first-child'
    },
    buttons: [
        {text: '<i class="fa fa-envelope">Send</i>'},
        {text: '<i class="fa fa-trash text-danger">Delete</i>'}
    ],
    // dom: 'Bfrtip',
    dom: 'Bfti',
    scroller: {
        loadingIndicator: true
    },
    stateSave: true,

    serverSide: true,
    ajax: function ( data, callback, settings ) {
        // console.log(data.start, data.length, data, callback, settings);

        var out = [];

        for ( var i=data.start, ien=data.start+data.length ; i<ien ; i++ ) {
            out.push( {id:  i, email: "t" + i+'.gmail.com', name: 'bob jones, just some words to make sure this scrolls' + (i * i) } );
        }
        setTimeout( function () {
            callback( {
                draw: data.draw,
                data: out,
                recordsTotal: 1000,
                recordsFiltered: 1000
            } );
        }, 10 );
    },
    columns: columns,
});

Thanks,

Tac

Width of thead th column does not align with tbody td column

$
0
0

When my table thead column width and tbody column width does not match.

th element is taking the width of header text while tbody columns width are taking the length of data
which has caused table head and body not aligned properly.

My code:

var GetForm = function (token, formType) {

    //$.fn.dataTable.ext.errMode = () => alert('Error Occurred.. please contact admin...');

    var EditFormsDivToUpdate = $('#adminEditOrderFormId');

    EditFormsDivToUpdate.html("");

    var table = '';
    table += '<table id="editFormTable" class="table table-condensed table-bordered table-responsive table-hover xdash-card-table" style="font-size:10px; width:100%">';
    table += '<thead style="font-size:10px; background-color:#495c89; color:#fff">';
    table += '<tr>';
    table += '<td>Id</td>';
    table += '<td>Name/Description</td>';
    table += '<td>SKU</td>';
    table += '</tr>';
    table += '</thead>';
    table += '</table>';

    EditFormsDivToUpdate.html(table);



    var table = $('#editFormTable').DataTable({
        "ajax": {
            url: "/MyWebApp/Admin/OrderForm",
            headers: { "__requestverificationtoken": token },
            type: "POST",
            data: {
                "form": formType
            },
            datatype: "json"
        },
        "columns": [
                { "data": "ID", "name": "ID"},
                { "data": "Description", "name": "Description"},
                { "data": "OrderSKU", "name": "OrderSKU" }


        ], 
        scrollY: '70vh',
        scrollCollapse: true,
        paging: false,
        fixedHeader: "true",
        //autoWidth: false,
       responsive: true
    });


    $('#editFormModel').modal('show')
} 

moment.js sorting 'MM/DD/YYYY h:mm:ss a' format not working

Automate entry in a field

$
0
0

Hi,
I have two tables: “tb_detalles” y “tb_palabras”, united by a third table, “detalles_palabras”. This last table contains two fields: “detalles_id” y “palabras_id”, which are the main key and which are related to the id of each of the respective “tb_detalles” y “tb_palabras”.
With the Datatable editor I can fill a column with multiple words for each record:

detalles_palabras (table)
detalles_id palabras_id (fields)
12 2
12 7
12 15
17 2

The summary code that I am using is the following:
$.fn.dataTable.Editor( {
fields: [
{
label: "Pal. Clave:",
name: "tb_palabra[].id",
type: "select2",
opts: {
"placeholder": "Select State",
"multiple": "multiple",
"allowClear": true
}
},
]
} );

$('#imagen_tbl').DataTable( {
columns: [
{ data: "tb_palabra", render: "[, ].palabra" },
]
} );

....................................................

Data:

Editor::inst( $db, 'tb_detalle' )

->join(
    Mjoin::inst( 'tb_palabra' )
    ->link( 'tb_detalle.id', 'palabra_detalle.detalle_id' )
    ->link( 'tb_palabra.id', 'palabra_detalle.palabra_id' )
    ->order( 'palabra asc' )
    ->fields(
        Field::inst( 'id' )
        ->validator( Validate::required() )
        ->options( Options::inst()
            ->table( 'tb_palabra' )
            ->value( 'id' )
            ->label( 'palabra' )
        ),
        Field::inst( 'palabra' )
    )
    ->where( 'palabra_detalle.modo_id', 1 )
)

)

I want to add a new functionality and I need, that the table: “detalles_palabras” differentiate the data from other tables. For that I added a new field: “modo_id”

(Before)
detalles_palabras (table)
detalles_id palabras_id (fields)
12 2
12 7
12 15
17 2

(Now)
detalles_palabras (table)
detalles_id palabras_id modo_id (fields)
12 2 1
12 7 1
12 15 1
17 2 1
Data from a second Datatable
12 7 2
12 15 2
23 7 2
Data from a third Datatable
12 15 3
23 7 3
23 5 3

The question is: How can I do that when I add a word from each of the datatables, I automatically insert the data in the field mode_id, with the information of the corresponding table. With the example code, it would be a 1.

Thank you very much and happy year to all.

Viewing all 79542 articles
Browse latest View live




Latest Images