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

Get filter / search value on page load

$
0
0

Hi,

I'm using this code to display a warning if filter is applied.
The reason is that the filter form may be toggle and I want the user see that filter is applied because stateSave keep the filter value in memory.

It is working fine when applying using the filter or do a search but how can I check on page load....

    table7.on('search.dt', function() {                     
            // check datatables search
            if (table7.search(this.value) != "") {
        $('#users-list_filter input').addClass('dfilter_applied'); 
            } else {  
            $('#users-list_filter input').removeClass('dfilter_applied'); 

            }

           // check yadcf filters 
           if ( yadcf.exGetColumnFilterVal(table7, 0) != ""  )  
            {
              $('#users_7').show(); 
            } 
            else {  
                $('#users_7').hide(); 
            }

    });

Also how can I echo / console.log the filter value (I mean the value used by the filter / search box, not the result)?

Thanks


change default route when export

$
0
0

When I export I want to save the result in a route, how can I change that route

$('#table').DataTable({

    dom: 'Bfrtip',
    buttons: [{
      extend: 'pdf',
      title: 'table',
      filename: 'table'
    }]
  });

Thank you

How to properly setup a responsive table?

$
0
0

I enabled responsive:

{ responsive: true; }

This technically works, as the columns will start to auto hide on page resize. However this triggers two issues:

  1. The table width is given a fixed size, which breaks the layout.
  2. The hiding of the columns only seem to happen on resize, and not when the page loads. So when I reload the page, all columns are there.

I read several times the docs, but can't seem to understand what's the proper behavior. I know I can setup breakpoints, but that still sets a fixed width to the table. I would like to keep the table size at 100%. I tried forcing the size via css !important, but that just breaks the hiding of the columns.

The docs show, severals responsive options, but fail to show these options showing together.

Thank you.

Footer Aggregate For Computed Column

$
0
0

Hello, I am having an issue where the suggested method of summing a column and placing it in the footer is not working for my computed column. I suspect it is because the data for the this column is null For example this is what my column looks like

{
    data: null,
    'render': function (data, type, full, meta) {
        var doubles = full['InvoiceTotal'] * 2;
        return doubles;
     }
}

The code I am using to sum the column in the footer callback looks like this

"footerCallback": function (row, data, start, end, display) {

                var api = this.api(), data;

                // Remove the formatting to get integer data for summation
               
                  var intVal = function (i) {
                    return typeof i === 'string' ?
                        i.replace(/[\$,]/g, '') * 1 :
                        typeof i === 'number' ?
                        i : 0;
                };

                // Total over all pages
              
                  var total = api
                    .column(11)
                    .data()
                    .reduce(function (a, b) {
                        return intVal(a) + intVal(b);
                    }, 0);

               $(api.column(0).footer()).html("Double Total:");
               $(api.column(1).footer()).html(accounting.formatMoney(total));
},

I do have a column aggregate that is working fine on the same table using the same method that is not a computed column. Is there a way to aggregate my computed column?

Need help with individual column footer select filter with serverside

$
0
0

Hi.. I cant figure out how to add my individual column footer select choice to the search filter, and could need some help.
If I didn't use server side (tested with example from this page) the select work just fine, but with my limited knowledge I can't figure out how to add it.
in my php script that the Ajax call I have a sql query like

$query .= "SELECT * FROM table WHERE ";
if(isset($_POST["search"]["value"]))
{
    $query .= '(column1 LIKE "%'.$_POST["search"]["value"].'%"';
    $query .= 'OR column2 LIKE "%'.$_POST["search"]["value"].'%")';
}

with this query I can only use the search box with column1 and column2. I could add the other columns easily but that is not the goal here.
In order for the selects to work should I have to add the selected value to the Ajax call? or is there some other way to filter the table after the table has been loaded? I would prefer that the Ajax call query was just the "select *" and then the build in search function just worked with serverside but im out of ideeas.

This is the call i have now that adds the select on column 7,8,9 and 10.

var dataTable = $('#user_data').DataTable( {
    "processing": true,
    "serverSide": true,
    "ordering":false,
    "ajax":{
        url:"../fetchshift.php",
        type:"POST"
    },
    initComplete: function () {
        this.api().columns([7,8,9,10]).every( function (i) {
            var column = this;
            var select = $('<select class="filter-select'+i+'"><option value="">Show All</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 ) {
                select.append( '<option value="'+d+'">'+d+'</option>' )
            } );
        } );
    }
} );

Blank table to use for bulk imports

$
0
0

Hi,
I have something I need to find a solution to, and I'm wondering if Datatables + Editor can handle it.

Basically, we need a way for people to scan or type in information and then upload that to our db either all at once, or by using the inline feature. I had thought about creating a blank table to accomplish this. I have this created, but I have a question.

If I have column headers that match the DB but the rest of the column is blank, is there a way that I can then have users fill in the blanks and have the data write back to the corresponding column in the database? Basically, I need datatables only to POST data to the server instead of pulling data out to display.

Is this doable? Is there any other method of accomplishing bulk imports?

Can a column be defined to render different for view vs Printing?

$
0
0

I have been reading about the columns.render option but I can't figure out from what I am reading if I can have different rendering for options like Print, PDF, Excel vs the displayed data on the table.

I see options for sort and display but not for export or print. Since Print, PDF, Excel are built in I was hoping that I can render differently for them.

For example I am using ellipsis.js to render a long title.
It displays the text truncated but I would like the excel export to contain the full text. For this field I would probably like shortened text for print but perhaps not. Ideally if I can control print, excel, pdf, copy differently that would be great.

I tried searching the forums for this topic but failed to find. Sorry if I missed obvious posts. I did try to research this as much as possible first.

Another example I have is a column I am have which lets a user take action based on buttons in the column. I have a column called "assigned to" which displays who a project is assigned to. When I render this I want to add a button for "assign to me". At first I did this by just returning HTML and adding some javascript to render these buttons and that is working but the text "assign to me" is included in the print options which I don't want. So I plan on writing my own render to add this button. But I want that renderer to NOT included the button when printing or exporting.

I hope this all makes sense. Thanks to anyone that can point me in the right direction of an example which does what I am trying to do or to some more documentation that might explain how it's done.

I can post example if needed but I think the case is simple enough. Let me know :smile:

Select2 editor field plugin

$
0
0

There seems to be an issue where the plugin makes a redundant ajax call for new records.

/api/GetNames?initialValue=true&value=%22%22

Looking at the plugin code I changed code at line 103 to the following to fix the problem:

if ( conf.opts && conf.opts.ajax && val ) {

I'm not sure this is the optimal way to correct this, but it does give me the desired result.


How to sort the table based on the aggregate value

How correctly and what is the difference?

$
0
0

Copy code

  1. document.write(unescape(""));
    or

  2. Copy code

    when I can not use <script>?

autoClose don't work for collection Button

$
0
0

Hello @allan

The option autoClose don't work for collection if option background is false .

The code problem is here.. I think... =P

PS: if I click inside the datatable, the collection is closed normally!

Dynamically added rows and rowReorder

$
0
0

I would like to know if there is possible to add the row reorder functionality in a datatable which is already initialized and the rows of this table are dynamically added by the user.
1. $("#table").DataTable({}); is already added.
2. The users through an input add rows to the table.
And of course if there is a way, how can I do it?

How do We Search A Records In Datatables On Input Focus ?

$
0
0
  1. I Am Passing Value In Search Box Using Jquery But it's not working for search I Have to move my cursor Then it's working (maybe search box default event is keyup ) so how do I make work when it gets focused.

                $('#ga-search').val(startdate);
    
    
                $('#employee-grid_filter input[type=search]').focus();
    

Responsive - How can I display the expand/collapse icon in the right side of the first column's valu

$
0
0

How can I display the expand/collapse icon in the right side of the first column's value?

How can I update a table caption dynamically?

$
0
0
var dTable = $('#table').DataTable();

I've tried both of the below. Obviously missing something simple.

dTable.caption().text('Details For ' + pParam);
dTable.caption('Details For ' + pParam);

Thanks in advance.


Next button does not show sorted order

$
0
0

Hello everyone,

I have a Datatable, every row has an action button where I can press edit, it opens a popup window where I can modify records and press next to see next row information data.

If I make a test and I sort for a column, for example name desc and then i press edit and next button, the records are not displayed like I sorted (name desc) but as default.

Is there a way that allows me to display data with next button like I sorted?

Thanks,

Nico

DataTable export in xlsx

$
0
0

Hi,
i want to export datatables value in excel file but when i have a number greater than 15 cifres, excel report has the scientific notation, with exponent.

I try to render the data with a space in the data field but did not work.
What i could try?

Thanks.

Pdf export issue

$
0
0

Hi Allan,

You have written this but the link does not working which you shared it us in text
Could you please again shared us correct link.
Thanks a lot

"Hi all,

Thanks to everyone for the input! I've just committed a number of changes to the PDf handling in TableTools, which will now allow the paper size and orientation to be set. Also the ability to include a title and summary message are present. See this post for more: http://datatables.net/forums/comments.php?DiscussionID=3726&page=1#Comment_17523 . This will be released as TableTools 2.0.1 soonish :-)
"

Datatable worked normally in my localhost but when i published it doesn't work ?

$
0
0

Datatable worked normally in my localhost but When I publish my site , an error appears " Ajax Error: tn/7"
when I open my console , the error is: 404 - Not Found.
The URL requested was not found on the server.
Any Help please?

How would you reorder a row using drag and drop on a paginated table?

$
0
0

The example for reorder rows shows a paginated table, but there is no way to get item 11 to number 10. Would the user have to change the number items displayed to 20 instead of 10, or is there away to do it otherwise?

Viewing all 82245 articles
Browse latest View live