Quantcast
Channel: Free community support — DataTables forums
Viewing all 35317 articles
Browse latest View live

How to search for a range with different digit count

$
0
0

I'm applying a "search" filter to limit to a range of values.

This works: table.column(9).search('[0-1][0-9]|2[0-5]', true, false).draw();

to find values from 10 - 25, but I also need it to include values from 0-9. I don't know what syntax to use to get the result in this jsfiddle:

http://jsfiddle.net/rvgraham/Up2f2/

In other words, I don't know the syntax to supply as a string that will "OR" one digit numbers or two digit numbers. I can only get it to "OR" different two digit combinations.

Did more research, this also works:

table.column(9).search('1\\d|2[0-5]', true, false).draw(); (to get 10-25)

So why doesn't this work: table.column(9).search('\\d|1\\d|2[0-5]', true, false).draw(); to get 0-25???

In fact, how would you force it to match an exact regex? Using '0' matches any value with 0 anywhere, and it seems to ignore the ^ and $ begin/end switches.

OK, ANSWERED myself...

The column is rendered with a percent sign. Looking "under the covers" it appeared tto me that the regex was being compared to the data value (an integer), not the text value with the percent sign.

This does the job: table.column(9).search('^\\d%$|1\\d|2[0-5]', true, false).draw();

Thanks in advance, Bob


sorting problem

Column text showing blank when text starts with

$
0
0

var testdata = [ { "id": 1, "name": "Peppermint Hot Chocolate","type": "Chocolate Beverage", "calories": "440", "totalfat": "16g", "protein": "13g"},{ "id": 2, "name": "<html Allan","type": "Chocolate Beverage", "calories": "440", "totalfat": "16g", "protein": "13g"}];

var oTable = $('#example').dataTable( { "aaData": testdata, "bAutoWidth": false, "aoColumns": [ { "mData": "name" , "sWidth": "45%" }, { "mData": "type","sWidth": "25%" }, { "mData": "calories","sWidth": "10%" }, { "mData": "totalfat" ,"sWidth": "20%"} ] } );

check test data second array -> name : "<html Allan"," text not displaying

Save state option only remembers single column sorting?

$
0
0

I am trying to implement multi column sorting, filtering and paging (server-side). Everything works properly. Now I want to save my table state (sorting, paging filtering). This works for paging and filtering. However it seems that it only "remembers" one sort column instead of all sorted columns. Is that correct? I am using the bStateSave option.

Custom Filtering - Range Search Performance Issue

$
0
0

Hello

I am trying to apply a custom range filter to my DataTable, following the example give at http://datatables.net/examples/plug-ins/range_filtering.html

However, I am running into an issue with performance/responsiveness of the DataTable after applying this filter. It seems that the function passed to push() needs to execute every time anything happens with the table (columns being sorted, table being searched or filtered, etc.) instead of just when you want to use the filter. Additionally, this function will run once for every row in the table whenever an action is performed on the table.

For instance, if you had a table with 100,000 records, and you decided to click one of the table headers to sort that column (an action unrelated to the custom range filter), this function would still need to execute 100,000 times resulting in an extremely slowed down responsiveness of the DataTable.

Does anyone have any suggestions for ways around this issue, or other ways of applying a range filter?

Thank you for you time.

Change data in specified cell if a row is selected

$
0
0

I am using the datatables from datatables.net I am trying to do something similiar to this http://datatables.net/examples/api/select_single_row.html

If i push on Button 1 the selected row should make the cell in column c change it's data from "f" to "p".

| A | B | C | D |

| 1 | # | f | # | <--- selected row

| 2 | # | p | # |

How am I going to code it? Would something like below work?

    $('#button').click( function () {
        table.row('.selected').table.column('c').value(p)
    } );

ColReorder 1.1.1 is not working with latest DataTable 1.10.1-dev

ColVis exclude to accept column name

$
0
0

I would like to ColVis accept the column name in exclude parameter.


fnSelect not working

$
0
0

Hi all,

in Datatables 1.10 with Tabletools 2.2.1 fnSelect is not working when the button has "sAction": "flash_save". If i uncomment sAction it works. Any Ideas??

Thanks, Martin

How to send request in JSON format with datatables editor

$
0
0

Sir, I am new to datatables editor. In it, I successfully get rows of data from server(which sends data in JSON format). When I edit a row, the data being sent to server is in URL parameters form. Can I send that data in JSON format? Is there any option which converts the URL parameters into JSON?

Thanks for your support

How to refresh table content using ajax when original table is dom based

$
0
0

Hello,

I have a datatable which is sourced from the dom (ie it's just html) when the page loads. However I'd like to be able to refresh the data on the page using ajax when a user enters a value and clicks a button.

I tried to simply build the new table on the button click (shown below), but the table does not update and the ajax call does not go out. Instead I get a undefined error on the datatables function.

$('form').submit(function(event) {

    event.preventDefault();

    var formData = {
      'member_id': $('input[name=member_id]').val()
    };

    $('#inventory-uniqueness').dataTable({
      "ajax": {
        "type": "POST",
        "url": "/inventory-uniqueness",
        "data": formData,
        "dataType": "json"
      },
      "columns": [{
        "data": "member_id"
      }, {
        "data": "member_name"
      }, {
        "data": "total_imps_seen"
      }, {
        "data": "num_sellers"
      }, {
        "data": "num_sellers_index"
      }, {
        "data": "weighted_num_sellers"
      }, {
        "data": "weighted_index"
      }
      ],
      "dom": 'T<"clear">lfrtrip',
      "tableTools": {
        "sSwfPath": "//cdn.datatables.net/tabletools/2.2.1/swf/copy_csv_xls.swf",
        "aButtons": ["csv", "xls", "copy"]
      },
      "order": [7, 'desc'],
      "scrollY": "600px",
      "bDestroy": true,
      "paging": false,
      "language": {
        "emptyTable": "No results found",
        "zeroRecords": "No results found",
        "processing": "<div align='center'><img src='/static/sonrun.gif'></div>",
        "loadingRecords": "<div align='center'><img src='/static/sonrun.gif'></div>"
      }
    });

});

Child rows (show extra / detailed information)

$
0
0

https://datatables.net/examples/api/row_details.html i am working on this link,here we can show extra information.i am using this ajax method.it show only 100 records.but i have 24000 records.how can fetch all records. mycode is..paging display only 100 records.

jquery

/* Formatting function for row details - modify as you need */ function format ( d ) { // `d` is the original data object for the row return ''+ ''+ ''+ ''+ ''+ ''+ ''+ ''+ ''+ ''+ ''+ ''+ ''+ '
Full name:'+d[6]+'
Extension number:'+d[7]+'
Extra info:And any further details here (images etc)...
'; } $(document).ready(function() { var table = $('#example').DataTable( { "ajax": "<?php echo base_url(); ?>home/user_record", "lengthMenu": [ [10, 25, 50, -1], [10, 25, 50, "All"] ], "columns": [ { "class": 'details-control', "orderable": false, "data": null, "defaultContent": '' }, { "adata": 0 }, { "adata": 1 }, { "adata": 2 }, { "adata": 3 }, { "adata": 4 } ], "order": [[1, 'desc']], "fnRowCallback": function( nRow, aData, iDisplayIndex, iDisplayIndexFull ) { //$(nRow).css('background', '#E2E4FF') //$('td:eq(0)', nRow).css('background', '#E2E4FF') //$('td:eq(0)', nRow).html(''+(iDisplayIndex+1)+'') //if(iDisplayIndex%2==0) //{ //$colour="RED"; //} //else //{ //$colour="#FFFFFF"; //} switch(aData[5]){ case '1': //$(nRow).css('background', $colour) //$('td:eq(0)', nRow).css('background', $colour) $('td:eq(5)', nRow).html('home/status/'+aData[0]+'" title="Edit"> | ring_adminback/home/status/'+aData[0]+'" title="Block">') //$('td', nRow).css('color','GREEN') break; case '0': //$(nRow).css('background', $colour) //$('td:eq(0)', nRow).css('background', $colour) $('td:eq(5)', nRow).html('home/status/'+aData[0]+'" title="Edit"> | ring_adminback/home/status/'+aData[0]+'" title="Block">') //$('td', nRow).css('color','GREEN') break; case '2': //$(nRow).css('background', '#FFC4D3')Delete //$('td:eq(0)', nRow).css('background', '#FFC4D3') $('td:eq(7)', nRow).html('admin_back/update_user_login/'+aData[0]+'" title="Edit"> | ring_adminback/home/status/'+aData[0]+'" title="Enable">') //$('td', nRow).css('color','Red') break; case '3': //$(nRow).css('background', '#FFC4D3')Delete //$('td:eq(0)', nRow).css('background', '#FFC4D3') $('td:eq(7)', nRow).html('admin_back/update_user_login/'+aData[0]+'" title="Edit"> | ring_adminback/home/status/'+aData[0]+'" title="Enable">') //$('td', nRow).css('color','Red') break; } } } ); // Add event listener for opening and closing details $('#example tbody').on('click', 'td.details-control', function () { var tr = $(this).closest('tr'); var row = table.row( tr ); if ( row.child.isShown() ) { // This row is already open - close it row.child.hide(); tr.removeClass('shown'); } else { // Open this row row.child( format(row.data()) ).show(); tr.addClass('shown'); } } ); } );

html code

Username Category Mobile Date Process
Username Category Mobile Date Process

fetched data

{"sEcho":0,"iTotalRecords":29270,"iTotalDisplayRecords":29270,"aaData":[["121","Hotel","Hotels and Restaurants","01141501234","2010-07-29 15:05:18","0","THE IMPERIAL New Delhi","luxury@theimperialindia.com"],--continue

Is it possible to restrict what parameters are posted on the ajax url

$
0
0

If I am using Server Side paging but the only parameters I need to pass are draw, start and length.

I have no need for all the search and various things to be passed.

The reason is in Asp.net MVC a security protection kicks in because the URL becomes to long after a certain amount of columns are created. It is possible to fix this in the config files but being as I dont need all this extra data id rather disable it if possible.

Just to give an example this is how much is being posted that isn't required on a 10 column table.

[SOME_URL]?draw=1&columns%5B0%5D%5Bdata%5D=0&columns%5B0%5D%5Bname%5D=&columns%5B0%5D%5Bsearchable%5D=true&columns%5B0%5D%5Borderable%5D=false&columns%5B0%5D%5Bsearch%5D%5Bvalue%5D=&columns%5B0%5D%5Bsearch%5D%5Bregex%5D=false&columns%5B1%5D%5Bdata%5D=1&columns%5B1%5D%5Bname%5D=&columns%5B1%5D%5Bsearchable%5D=true&columns%5B1%5D%5Borderable%5D=false&columns%5B1%5D%5Bsearch%5D%5Bvalue%5D=&columns%5B1%5D%5Bsearch%5D%5Bregex%5D=false&columns%5B2%5D%5Bdata%5D=2&columns%5B2%5D%5Bname%5D=&columns%5B2%5D%5Bsearchable%5D=true&columns%5B2%5D%5Borderable%5D=false&columns%5B2%5D%5Bsearch%5D%5Bvalue%5D=&columns%5B2%5D%5Bsearch%5D%5Bregex%5D=false&columns%5B3%5D%5Bdata%5D=3&columns%5B3%5D%5Bname%5D=&columns%5B3%5D%5Bsearchable%5D=true&columns%5B3%5D%5Borderable%5D=false&columns%5B3%5D%5Bsearch%5D%5Bvalue%5D=&columns%5B3%5D%5Bsearch%5D%5Bregex%5D=false&columns%5B4%5D%5Bdata%5D=4&columns%5B4%5D%5Bname%5D=&columns%5B4%5D%5Bsearchable%5D=true&columns%5B4%5D%5Borderable%5D=false&columns%5B4%5D%5Bsearch%5D%5Bvalue%5D=&columns%5B4%5D%5Bsearch%5D%5Bregex%5D=false&columns%5B5%5D%5Bdata%5D=5&columns%5B5%5D%5Bname%5D=&columns%5B5%5D%5Bsearchable%5D=true&columns%5B5%5D%5Borderable%5D=false&columns%5B5%5D%5Bsearch%5D%5Bvalue%5D=&columns%5B5%5D%5Bsearch%5D%5Bregex%5D=false&columns%5B6%5D%5Bdata%5D=6&columns%5B6%5D%5Bname%5D=&columns%5B6%5D%5Bsearchable%5D=true&columns%5B6%5D%5Borderable%5D=false&columns%5B6%5D%5Bsearch%5D%5Bvalue%5D=&columns%5B6%5D%5Bsearch%5D%5Bregex%5D=false&columns%5B7%5D%5Bdata%5D=7&columns%5B7%5D%5Bname%5D=&columns%5B7%5D%5Bsearchable%5D=true&columns%5B7%5D%5Borderable%5D=false&columns%5B7%5D%5Bsearch%5D%5Bvalue%5D=&columns%5B7%5D%5Bsearch%5D%5Bregex%5D=false&columns%5B8%5D%5Bdata%5D=8&columns%5B8%5D%5Bname%5D=&columns%5B8%5D%5Bsearchable%5D=true&columns%5B8%5D%5Borderable%5D=false&columns%5B8%5D%5Bsearch%5D%5Bvalue%5D=&columns%5B8%5D%5Bsearch%5D%5Bregex%5D=false&columns%5B9%5D%5Bdata%5D=9&columns%5B9%5D%5Bname%5D=&columns%5B9%5D%5Bsearchable%5D=true&columns%5B9%5D%5Borderable%5D=false&columns%5B9%5D%5Bsearch%5D%5Bvalue%5D=&columns%5B9%5D%5Bsearch%5D%5Bregex%5D=false&start=0&length=99&search%5Bvalue%5D=&search%5Bregex%5D=false&_=1404523861774

Which should be really more like (for me)

[SOME_URL]?draw=1&start=0&length=100

Implement to DataTables 1.10.1 row.insert()

$
0
0

Implement something like row.insert(0, ["1","2","3"]) to add row to the beginning (index 0) with data ["1","2","3"].

Exporting filtered data does not work

$
0
0

Hi, I have a problem when I try to export data after applying a filter. I read a discussion suggesting to use oSelectorOpts but it's not working for me. This is the code I use to initialise the table: $(document).ready( function () { $('#example').dataTable( { "sDom": 'T<"clear">lfrtip', "tableTools": { "sSwfPath": "./swf/copy_csv_xls_pdf.swf" }, "oTableTools": { "aButtons": [ { "sExtends": "copy", "oSelectorOpts": { filter : "applied" } } ] } } ); } );

Do you have any idea why it's not working?

thanks


Not getting correct search result on jQuery datatable.

$
0
0

I have applied jQuery dataTable on a asp DataGrid. In this data grid in first column I have a hyper-link on the value of cell. Lets say the ID of the link is coming as DataGridID_lnkID02.. and so on. Now, when I am searching on the jQuery table using the Search Textbox, I am NOT getting correct result. When I am searching value "lnk", all records are filtered although non of the cells contains text containing "lnk". (id of hyperlinks contains 'lnk').

Can someone help me fixing it?

Custom Filter Toggle on hidden column

$
0
0

I've got a table with color coded table rows. There is a key at the top of the table that shows what the colors mean and is also clickable to filter the table by the keys. Riffing off the official custom filter example and a post in the forum that was quasi on target with what I wanted to accomplish I tried a few things. I got the filter by tr class name working but that only filtered items in the dom that had a class. everything paginated was skipped. So I decided filtering by class name was a bad idea. I added a column to the table and put the info I wanted to filter by in there but that only worked when it was visible. Hiding the column broke the filter. And that's where I'm at now... How can I get a filter using a hidden column or, should I be taking a completely different route?

I made this.

How to sort a-b-c data in row (1.10.0)

$
0
0

Hello, please help me sort a row with a-b-c data, for example: 95-75-6

Where must sort in order A, B, C. For example, sort like this:

100 - 40 - 3

100 - 37 - 2

90 - 47 - 10

90 - 47 - 9

87 - 3 - 10

83 - 34 - 11

Thank you.

Accessing cell data and HTML elements

$
0
0

I'm having difficulty finding the right syntax to get to the underlying data for a cell and the actual <TD> element for the cell. Briefly, the first column of the table contains checkboxes. The data is JSON and each object in the array has a "manuallychecked" key/value pair which indicates whether the row was checked one-by-one. The user can also toggle all checkboxes on/off, and when they're toggled off, the idea is that we restore the manually-checked states.

I am trying to loop through each row and check the manuallychecked flag in the underlying data, and then access the checkbox element in the <TD> to set the checked property. I think I'm pretty close:

function gridToggle() {

    // if true, ignore manuallychecked; if false, refer to manuallychecked
    allChecked = !allChecked;

    // grab one of these because we use it multiple times
    var api = summaryGrid.api();

    // loop through each row
    api.rows().each(function(val,idx) {

        // clearly something goes wrong
        // i have 16 rows but i get to this point just once; idx = 0
        // but cel appears to be a valid DT cell() object
        var cel = api.cell(idx,0);

        // cel.data().manuallychecked is "undefined" instead of true/false
        var chk = allChecked || cel.data().manuallychecked;

        // this doesn't throw errors but nothing happens; i suspect node() isn't right?
        $(cell.node()).find("input:checkbox").prop("checked", chk);
    });
}

How can i put the sInfoFiltered text on the top of table instead of the bottom ?

$
0
0

Usually sInfoFiltered text comes below the table data, how can i put it above the table, somewhere beside sLengthMenu.

Viewing all 35317 articles
Browse latest View live