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

Child row button colour using Bootstrap styling

$
0
0

The child row button seems to use text-primary colour, which appears to have hardcoded since it doesn't match any user themes that already override Bootstrap's text-primary.

For example my text-primary is green, but DataTables text-primary is still the default blue? How do I fix this?


Need to use the create a link in new tab functionality of Google Chrome.

$
0
0

When I use the datatables it is giving me a blank page if I use the right click of the mouse. If I click on hte link I get the page displayed in the same window.

What directive I need to use with datatables to allow that.

Is it possible to disable Editor's create method in .NET library?

$
0
0

I have one case where I wish to create the new database entry externally in WriteCreate event.
I do not wish Editor .NET library to attempt to create a row.
So I tried adding .Set(false) to all fields, but this produces the error: "Object reference not set to an instance of an object."

Kind regards,
Kevan

Editor Buttons Not showing up

$
0
0

My Editor buttons are not showing up.
I have a table that is supposed to display info based on the type of record it is retrieving.
The create, edit, remove buttons dont show up on my table.
As well:
My table columns are fetched dynamically and pushed to an array so it can be used.

The editor fields seem to be set in a static way, so I cant find a way to add them correctly,
This makes it so i cannot edit inline

/***
 * Client side script to process Datatable for Payment Schedule
 * main is created with possibility of exposing functions but nothing is exposed right now except round
 * @context : pSchedule
 */
; //in case of namespace pollution, close any open client side script.
/**
 * Important to pass jQuery
 * @param $
 * @param pSchedule
 * @param window
 * @param document
 * @param undefined
 */

var mainSsu = 'https://system.sandbox.netsuite.com/app/site/hosting/scriptlet.nl?script=808&deploy=1&compid=173762&columns=';
$(document).ready(function() {
    //  var suiteletTable = $('#ps_mainsuitelet').DataTable();
    var recordId = $('#recordid').val();
    var recordType = $('#recordtype').val();
    var columns = $('#columns').val();
    console.log(columns);
    var columnslabels = $('#columnlabels').val();
    console.log(recordId + ' ' + recordType + ' ' + columnslabels);
    var headers = '';
    columnHeadersArray = columnslabels.split(',');

    $('#ps_mainsuitelet thead tr').append('<th>LineId</th>');
    for (var i = 0; i < columnHeadersArray.length; i++) {
        $('#ps_mainsuitelet thead tr').append('<th>' + columnHeadersArray[i] + '</th>');
    }

if(recordType == "salesorder")
{
    var editor = new $.fn.dataTable.Editor({
        ajax : '/api/staff',
        table : '#ps_mainsuitelet',
        fields : [
        {
            label : 'Do Not Print',
            name : 'custcol_dont_print_line_item',
        },
        {
            label : 'Line',
            name : 'line',
        },
        {
            label : 'Mfg Code',
            name : 'first_name',
        },
        {
            label : 'PO Vendor',
            name : 'povendor',
        }
                ]
    });

}
    //  var url = mainSsu + '&recordInternalId=' + recordId + '&recordType=' + recordType + '&actiontype=setValues';
    jQuery.get(mainSsu + encodeURIComponent(columns) + '&recordInternalId=' + recordId + '&recordType=' + recordType, {
        actiontype : 'setValues'
    }).done(function(data) {
        console.log(data);
        createMainDataTable(data);

    });




    var mainSuiteletTable;
    function createMainDataTable(data) {
        mainSuiteletTable = $('#ps_mainsuitelet').DataTable({
            data : JSON.parse(data),

            fixedHeader : {
                header : true
            },
            paging : false,

            select : {
                style : 'os',
                selector : 'td:first-child'
            },

            buttons: [
            { extend: "create", editor: editor },
            { extend: "edit",   editor: editor },
            { extend: "remove", editor: editor }
                    ],

            columnDefs : [{
                className : 'select-checkbox',
                targets : 0

            },


            {
                className : 'select-checkbox',
                targets : [1],
                visible : false,
                searchable : false
            }]
        });
    }

    var selected = [];
    $('#checkboxes input:checked').each(function() {
        selected.push($(this).attr('name'));
    });

    // Activate an inline edit on click of a table cell
    $('#ps_mainsuitelet').on( 'click', 'tbody td:not(:first-child)', function (e) {
        editor.inline( this );
    } );

    $('#delete_button').click(function() {
        console.log('clicked button');
        var ids = $.map(mainSuiteletTable.rows('.selected').data(), function(item) {
            return item[1];
        });
        console.log(ids);
        var ids_string = ids.toString();
        //      var ids_to_send = jQuery.serialize(ids);
        jQuery.ajax({
            type : "POST",
            url : mainSsu + '&recordInternalId=' + recordId + '&recordType=' + recordType,
            data : {
                actiontype : 'delete',
                lineIds : ids_string
            },
            success : function(result) {
                console.log('draw');
                mainSuiteletTable.ajax.reload();
                //              mainSuiteletTable.draw(); // redrawing datatable
            }
        });
    });

});

RowReorder + editor don´t send post on drop

$
0
0

Hello

I have tried everything that has occurred to me and read other discursions with the same problem but I do not get that after performing a drag and drop send the post to the server. I try all, its very frustrating :(

If anybody can help me this is my code:

                var editor = new $.fn.dataTable.Editor({
                    ajax: '{{ path("template.record.rel") }}',
                    table: $('#dt_dato_plantilla'),
                    idSrc: "id",
                    fields: [
                        { label: "Descripción", name: "descripcion" },
                        { label: "Orden", name: "orden", message: 'Only drag & drop' }
                    ]
                });

                var dt = $('#dt_dato_plantilla').DataTable({
                    serverSide: false,
                    data: this.config.data,
                    columnDefs: [{
                        orderable: false,
                        targets: [1,2,3]
                    }],
                    rowReorder: {
                        dataSrc: 'orden',
                        editor:  editor,
                        update: true
                    },
                    columns: [
                        { data: "orden", title: 'Orden', width: 20, className: 'reorder' },
                        { data: "descripcion", title: 'Descripción', className: 'editable' },
                        {
                            data: "tipoDato",
                            title: 'Tipo de dato',
                            render: function (data, type, full, meta) {
                                return full.tipoDatoTxt;
                            }
                        },
                        { data: "id", visible: false}
                    ],
                    sDom: "<'dt-toolbar'<'col-sm-4 col-xs-6'B>>tr<'dt-toolbar-footer'>",
                    select: true,
                    buttons: [
                        { extend: "remove", editor: editor, text: '<i class="fa fa-trash-o"></i>' },
                        { extend: "edit", editor: editor, text: '<i class="fa fa-edit"></i>' }
                    ]
                });

                editor.on('postCreate postRemove', function () {
                    dt.ajax.reload(null, false);
                });

                editor.on('initEdit', function () {
                    editor.field('orden').disable();
                });

In the examples and in the documentation seems very simple. What am I missing?

Tanks!

Rendering a varying number of buttons in a column

$
0
0

I have a table that, based on a value in the data source, needs to render anywhere from one to three buttons. I found a page showing an example of how to use defaultContent to render a single button: https://datatables.net/reference/option/columns.defaultContent

However, that doesn't describe what to do when you have to render a varying number of buttons. I thought maybe I could pass a function to defaultContent but then I didn't know how to access the data to determine which buttons to render.

I actually already successfully render the buttons by including the html in the data, Below is an example of the code that generates the html for those buttons. A list of "assetInfo" objects is provided to the table. The jquery function provided at the bottom of this message, named getAssets(), retrieves the data for the table and then wires-up the "click" event to the buttons. You may be asking yourself then, "why am I posting this question here if I am already rendering buttons?" Sadly, this solution only sometimes works. I'll explain in a moment. As a result, I started questioning my implementation and began looking to see how datatables recommends rendering buttons in the table. That's when I discovered the above reference. At this point, I find myself with only a partial understanding of how to solve the problem.

The problem I'm having with my current implementation is that, when a user changes pages, sorts columns, searches, etc., the buttons often become un-clickable.

So, I either need to solve the problem of un-clickable buttons or change how I am rendering the buttons and wiring them up to the click event. What is the best way to render a varying number of buttons in each row?

Thank you.
Saxon

---- code sample showing the logic I am using to generate html to render multiple buttons ----

                    if (assetInfo.Status == "Available")
                    {
                        assetInfo.Actions =
                            $"<img class='ui-icon editAsset' title='Edit' data-assetId='{assetInfo.AssetId}' src='img/Icon_Edit.png'/>&nbsp;" +
                            $"<img class='ui-icon deactivateAsset' title='Deactivate' data-assetId='{assetInfo.AssetId}' src='img/Icon_Delete.png'/>&nbsp" +
                            $"<img class='ui-icon transferAsset' title='Transfer' data-assetId='{assetInfo.AssetId}' src='img/Icon_Transfer.png'/>";
                    }
                    else if (assetInfo.Status == "Assigned")
                    {
                        assetInfo.Actions =
                            $"<img class='ui-icon editAsset' title='Edit' data-assetId='{assetInfo.AssetId}' src='img/Icon_Edit.png'/>";
                    }
                    else //Deactivated
                    {
                        assetInfo.Actions =
                            $"<img class='ui-icon editReactivate' title='Reactivate' data-assetId='{assetInfo.AssetId}' src='img/Icon_Reactivate.png'/>";
                    }

----- The javscript function and ajax call that populates the table and wires-up the buttons to the click event ----

    function getAssets() {
        $.ajax({
            type: "POST",
            url: "Assets.aspx/GetAssets",
            data: "{organizationId: " + $("#ddAssetOrganization").val() + "}",
            datatype: "json",
            contentType: "application/json; charset=utf-8",
            success: function (response) {
                if (response.d.Success) {
                    if (!$.fn.dataTable.isDataTable("#tblAssets")) {
                        dtAssets = $("#tblAssets")
                            .DataTable(
                            {
                                data: response.d.AssetInfoList,
                                columns: [
                                    { data: 'AssetTagNumber', "title": "Asset #" },
                                    { data: 'SimNumber', "title": "SIM #" },
                                    { data: 'IMEI', "title": "IMEI" },
                                    { data: 'SerialNumber', "title": "Serial #" },
                                    { data: 'Status', "title": "Status" },
                                    {
                                        data: 'Actions',
                                        "orderable": false,
                                        "searchable": false,
                                        "title": "Actions"
                                    }
                                ],
                                order: [[0, "asc"]]
                            });
                    } else {
                        dtAssets.clear();
                        dtAssets.rows.add(response.d.AssetInfoList).draw();
                    }

                    $("#tblAssets").show();

                    $(".editAsset").click(function () {
                        $("#divAssetMessage").hide();
                        $("#ulErrors").remove();
                        getAssetDetail($(this).attr("data-assetId"));
                        $("#assetDialog").dialog({
                            title: "Edit Asset",
                            buttons:
                            {
                                "Update": function () {
                                    updateAsset();
                                },
                                "Cancel": function () {
                                    $("#assetDialog").dialog('close');
                                }
                            }

                        });
                        $("#assetDialog").dialog('open');
                    });
                } else {
                    alert(response.d.ErrorMessage);
                }
            },
            failure: function (response) {
                alert('Error getting the asset: ' + response.d);
            }
        });
    }

Cannot get DataTables date sort working with moment.js

$
0
0

Hello everyone, having trouble with this issue and have exhausted all of the forums looking for answers (mostly https://datatables.net/blog/2014-12-18 <- this blog post)

I want to use the moment.js plugin (described in above blog post) to sort a simple table

The following is in my code,

$(document).ready(function() {
//These are the formats I have tried, separately, and many combined
$.fn.dataTable.moment( 'MMMM DD, YYYY, hh:mm a' );
$.fn.dataTable.moment( 'MMMM DD, YYYY, h:mm a' );
$.fn.dataTable.moment( 'MMMM DD, YYYY, hh a' );
$.fn.dataTable.moment( 'MMMM DD, YYYY, h a' );
$.fn.dataTable.moment( 'MMMM D, YYYY, hh:mm a' );
$.fn.dataTable.moment( 'MMMM D, YYYY, h a' );
$.fn.dataTable.moment( 'MMMM D, YYYY, hh a' );
  $('#table_selector').DataTable({
      "order": [[ 1, "desc" ]]
   });
});

The actual table is rendered like this (It ends up being rendered as a non-ajaxy, static table):

{% for row in table_data %}
   <tr><td> {{row.name}} </td> <td data-order="{{row.date}}"><a href="...">{{row.date}}</a></td></tr>
{% endfor %}

Rendered, it looks like this

| John | June 9, 2017, 7:59 p.m. |
| Mary | June 7, 2017, 11 a.m. |
| Allan | June 12, 2017, 3 a.m. |

DT is attempting to sort the column I selected (notable by the down-caret in the header) but I clearly I initialized something incorrectly. There are no console errors, so I'm a bit lost. I know moment.js is loaded, as well as the datetime-moment.js referenced in the above blog post because I can reference them in the console without errors.I'm sure I'm doing something wrong, but can't figure out what!

Any tips?

Column Sorting US date format

$
0
0

Hi,
I have a column of dates which has this format MM/DD/YYYY. Sorting is not properly working for this format(MM/DD/YYYY). Could you help me?


is there any example of server side ajax response with more than 1 draw

$
0
0

I am having problem with client datatables when setting "serverSide": true
Datables is looping asking for new data
I must be doiing something wrong on my server side

Thanks in advance

Can DataTables do this?

$
0
0

Hello,

We're looking for something like a property view (see attached image).

It needs the following features and capabilities:

  • Have at least two columns, the left side being an uneditable label, the right side being an editable value.
  • Have expandable/collapsable nodes.
  • Have unlimited sub-nodes under each node
  • Display repeatable values
  • Each row should be drag and droppable. So row #5 can be dragged to the position of row #3 and it becomes the third row.

Can DataTables be made to do this?

Can DataTables render a column using mRender differently when it is rendering for "details" of a row

$
0
0

Is there a way to use the "mRender" within aoColumnDefs to render the text for the column to be different in the "details" version of the column vs. the normal version of the column when using a responsive table?

...did that make any sense?

Problem with columnDefs example page

$
0
0

I noticed a typo in one of the documentation pages.

https://datatables.net/reference/option/columnDefs

At the bottom at example, it says
"Disable filtering on the first column:"

but the code it gives you is
"searchable": false

when it should be
"filterable": false

And does anyone know where I can find all the attributes I can modify with column or columnDefs? Thanks

Unwanted horizontal scrollbar

$
0
0

I have a table where I want vertical scrolling but no horizontal scrolling. However, by setting a value for scrollY, a horizontal scroll bar is also displayed and I can't find a way to get rid of it. Apparently the horizontal bar is added to account for the space taken up by the vertical bar, so the horizontal scroll available is only a few pixels. This is completely unnecessary and doesn't look good. Is there a way to get rid of the horizontal scroll? Here is the table code:

dtFormulas = $('#tblFormulas').DataTable({
  ajax: 'sqlprocs.asp?proc=getformulas',
  dom: '<"top"f>rt<"bottom"ip><"clear">',
  scrollY: '350px',
  scrollX : false,
  scrollCollapse : true,
  paging: true,
  pageLength: 15,
  pagingType : 'full',
  select: {style: 'single'},
  columnDefs: [ {
    targets: 2,
    data: null,
    width: '50px',
    defaultContent: '<image src=edit.png title="Edit" class=editformula_png>&nbsp;<image src=delete.png title="Delete"   class=deleteformula_png>'
   } ]
});

Adding bootstrap data-toogle & data-target into data-table button

$
0
0

Hi everyone, I have an issue similiar to this, but I'm having trouble understanding the answer

Originally I have a button with bootstrap data-toggle in it

<button
    data-toggle="modal" data-target="#create_new_workorder"
    type="button" class="btn btn-sm btn-warning btn-outline"><span
    class="hidden-md hidden-sm hidden-xs">Create Workorder</span> <i
    class="fa fa-fw fa-plus"></i>
</button>

but now I'm using data-table button which looks something like this

buttons: [
    {
        text: 'Create Workoreder',
        action: function () {
            create_workorder_window();
        },
        className: 'btn btn-warning btn-outline'
    },
    { extend: 'colvis', text: 'Show', className: 'btn btn-warning btn-outline'}
],

how can I add the data-toggle="modal" and the data-target="#create_new_workorder"?

Any help is much appreciated

Input field value from data table only can be stored when at the active page

$
0
0

I want to store the value of input field from data table into database, but it only allows to save the page where is active only, the other field value will became null. For example, there are 2 pages of data, i only allow to save the data on current active page, other pages value will get null. Any solution to solve this issue?


Missing button (copy, csv, excel and pdf) on datatable of some browser

$
0
0

I use datatables in booster for develop and open all button (copy, csv, execl, pdf and print). I found problem on very browser on some PC. In show but print button and it not work! pls help!!!! :'(

Data table button not working

$
0
0

Hello Devs,

I am using data table plugin with 1.9.4 version and jquery version is 1.4.2 and want to use button for export record in excel file, But I got error like 'Uncaught TypeError: Cannot read property 'register' of undefined
at dataTables.buttons.min.js:28
at dataTables.buttons.min.js:5
at dataTables.buttons.min.js:5'

So can this button plugin is not supported for older version of data table or I am doing something wrong. Please help me.
Thanks for advance.

Update a value Change in a Datatable

$
0
0

Hello , i want to ask about how to update a value in a Datatable .
I change a value (with edit function) and after saving i expect to see the "new_value" all over at the same column .
Thanks for Help :)

Bugs with IE9

$
0
0

Hi!

Problem 1

When I test datatables in my Web application with IE9. There are only Copy and Print exports available.
When I test it on Firefox 45, all exports are appear namely Copy, Excel, CSV, PDF and Print.
It seems to have a bug with Internet Explorer 9.

Problem 2

Sometimes (not everytime), datatables are blocked on the loading state. By clicking on Next, it "debugs" it and the data appear in the datatables.

How to debug it?

Thank you in advance for your response.

Datatable check type of column like html , string , date

$
0
0

I am using "aoColumns": [null, { "sType": "html" } , null, { "sType": 'date' }]; in datatble options.
Using code i need to check the sType like
this.api().columns().every(function () {
var column = this;

// here i need to find the sType });

Any help please ?

Viewing all 82690 articles
Browse latest View live


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