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

Retain selection when Datatable uses Scroller with Serverside Data.

$
0
0

Hello Allan and Others,

Whenever scroller fetches new data, and draws the table again, my old selection is lost.
I want to retain all the selections. Does anyone have any ideas on how to avoid the table redraw and just append new data?

Thanks,
Sagar


v1.6 .NET compilation issues

$
0
0

While upgrading my app from 1.5.6 to 1.6.0, I ran into some thorny compile-time bugs in the new DataTables .NET code. I fixed them, but would like to know whether others are seeing the same issue, or whether my hacks will break something else down the road. Here are the problems I encountered in Visual Studio Premium 2013.

In abstract class Query.cs, the following lines gave syntax errors:

        internal virtual string _bindChar => "@";
        internal virtual string[] _identifierLimiter => null;
        internal virtual string _fieldQuote => "'";

so I regressed them to the 1.5.6 code:

        // Copied from v1.5.6 to fix compilation errors
        virtual internal string _bindChar { get { return "@"; } }
        virtual internal string _identifierLimiter { get { return ""; } }
        virtual internal string _fieldQuote { get { return "'"; } }

In addition, in method void _Prepare(string sql), I had to change the vars left and right to strings to work with String.Join:

         // did not compile in line 1012) return left + String.Join(right + '.' + left, a) + right + alias;
         var left = idl[0];
         var right = idl[1];

         // fix
         var left = idl[0].ToString();
         var right = idl[1].ToString();

There was one other issue as well but I can't recall it now. I'll append if I remember it later. Thanks for any guidance.

Fixed Header custom search filters in header issue on redraw

$
0
0

I've created a datatable which dynamically adds a thead row to the datatable. Each column in this new thead row has an input filter which filters on that specific column. This works great until I enable FixedHeader. In IE (I'm using IE11) When I type in one of the filters, causing a search to and then draw() to occur, I can no longer type in that input box even though the focus still remains there. I have to click on another input and then back into the original input for me to be able to type again.

I have created an example using the live.datatable.net page: http://live.datatables.net/lebojudi/1/edit

Does anyone know of a fix for this. Or at least a clue as to why this is happening. Seems to work fine in Chrome but I need it to work in IE.

Trouble with checkbox.

$
0
0

Hi, everyone.
Im trying to use a checkbox set to indicate in the editor form a set of optios which can be individually check or unchecked. Everything is ok if I define the options in the checkbox field definition. However, if I try to create the options dinamically, by using the preOpen event, all the options are shown unchecked.... just the first time I open the editor. The second, third etc times, the options are shown properly cheked or unchecked, depending on the data base contents. It only fails the first time I open the editor.

The field is defined like this:

{
    label: 'Especialidades:',
    name: 'id_especialidades[]',
    type: 'checkbox',
    fieldInfo: 'Selecciona las especialidades'
},

The options are loaded dinamically by the preOpen event, like this:

objetoEditor.on('preOpen', function(e, mode, action){
    if (action == "remove") return;
    $.ajax({
        url:"leer_especialidades_editor_08.php",
        async:false,
        dataType: "JSON",
        complete:function(datosRecibidos) {
            listaDeEspecialidades = datosRecibidos.responseText;
        }
    });
    var matrizDeEspecialidades = JSON.parse(listaDeEspecialidades);
    objetoEditor.field('id_especialidades[]').update(matrizDeEspecialidades);
});

Ant the field in the Datatables is defined like this:

{"data": 'id_especialidades[]'}

When I open the editor, the preOpen event gives the right JSON response from the first time, like this:

0:{label: "Bootstrap", value: "9"}
1:{label: "CSS 3", value: "3"}
2:{label: "HTML 5", value: "1"}
3:{label: "JavaScript 6", value: "2"}
4:{label: "jQuery", value: "7"}
5:{label: "jQuery Mobile", value: "10"}
6:{label: "jQueryUI", value: "8"}
7:{label: "MySQL", value: "6"}
8:{label: "PHP", value: "5"}
9:{label: "SCSS", value: "4"}

The first time I try to edit a user profiles, they appear all the checkboxes unchecked. If I close the form and reopen it, the checkboxes appear properly checked or unchecked, on the real sate in the MySQL table.

Why does it not work just the first time?

Thanks everyone.

Upgrade from 1.5.6 to 1.6.1

$
0
0

Hi Allan,

I downloaded and tried to upgrade to 1.6.1. I don't see any php file to be upgraded at all. Am I right? Thanks Allan.

With select-checkbox, appears, cannot check after refreshing table

$
0
0

I am using the select-checkbox className for a checkbox column which generally works well. I allow the user to select one or more rows and remove the items from the table (by deleting the row(s) in the database and refreshing the table). However, when attempting to check one of the remaining rows after refreshing, the checkboxes for the remaining items cannot be checked. I did a comparison of the html for the checkbox table cells and they both look the same (before and after removing/refreshing items from the table). Any ideas on how to troubleshoot this?

Thanks.
Tom

Error to show details

$
0
0

Hello!!

I'm create a Datatable with RowDetails

Radomly I recive this error:

Uncaught TypeError: Cannot read property '_detailsShow' of undefined
at u.<anonymous> (datatables.min.js:132)
at Function.isShown (datatables.min.js:114)
at HTMLTableCellElement.<anonymous> (monitoralertas.aspx:335)
at HTMLTableElement.dispatch (jquery-1.10.2.min.js:5)
at HTMLTableElement.v.handle (jquery-1.10.2.min.js:5)

This error appears when I click the button (+) on my Grid

Steps:
1) I have a filter section, when I push the button Search this button call to the function Buscar(). I use the filter section to launch the ajax Rq with parameters

..
function Buscar() {
document.getElementById("Datos").style.display = ""; //Poner el stulo del DIV
$('#KPIAlertas').DataTable().clear()
$('#KPIAlertas').DataTable().destroy()
$.fn.dataTable.moment('DD/MM/YYYY H:mm:ss');
var table = $('#KPIAlertas').DataTable({
dom: 'Bfrtip',
buttons: [
'copyHtml5',
'excelHtml5',
'print'
],
"ajax":
{
"url": "./ajax/alertas.ashx",
"type": 'POST',
"data": { "op": "GetAlertas", "a_codi": ObtenerFiltroCliente()}
},
"columns": [
{
"className": 'details-control',
"orderable": false,
"data": null,
"defaultContent": ''
},
{ "data": "Cliente" },
{ "data": "Alerta" },
{ "data": "Fecha" },
{ "data": "ValorTotal", "width": "10", "className": "dt-body-center" },
{ "data": "ValorRegistrado", "width": "10", "className": "dt-body-center" },
{ "data": "Valor", "width": "10", "className": "dt-body-center" },
{ "data": "ActualKPI", "width": "10", "className": "dt-body-center" },
{
"data": function (data, type, row, meta) { if (data.FechaRevisada == "") return false; else return true; }, "width": "10", "className": "dt-body-center",
"render": function (data, type, row, meta) {
if (row.FechaRevisada == "") {
return "<img id=IRes_" + row.id_ale + " src='./img/PRevisada.png' onclick='VerificarAlerta(" + row.id_ale + ",1)' />";
}
else {
return "<img id=IRes_" + row.id_ale + " Title='" + row.FechaRevisada + "'src='./img/Revisada.png' onclick='VerificarAlerta(" + row.id_ale + ",0)'/>"
}
}
}
],
"order": [[1, 'asc']],
"pageLength": 25,
"language": {
"url": "./lang/datatable.json",
buttons: {
copy: 'Copiar',
copyTitle: 'Copiado al portapapeles',
copySuccess: {
_: '%d lineas copiadas',
1: '1 línea copiada'
},
print: 'Imprimir'
}
}
});
// Add event listener for opening and closing details
$('#KPIAlertas').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
//var childrenHtml = ObtenerHTML(row.data());
ObtenerHTML(row.child, row.data())
// row.child(childrenHtml).show();
tr.addClass('shown');
}
});

    }

...

Can you help me?

How to sync footer with body scroll position

$
0
0

Hi,

When the footer has a column search input, and the user tabs to an input element just off screen but within the next footer cell, the tbody scroll position does not get updated, and so the grid looks like two separate tables (which, heh, of course it is).

Is there a programmatic way i can fix this? Something like jQuery on input has focus event, update tbody scroll position.if not on screen...


Datatables with MultiFilter, MultiFilterSelect and Preselection (Search AND Select Filter)

$
0
0

See this fiddle:
https://jsfiddle.net/ckmuc/83n1uxsd/7/

Most of my needs do work - however I cannot find out, on how to combine a "Select Filter" and a search when initially loading the page.

When running the fiddle, the search for '2009' is already working. I would also like the "Office" dropdown to be populated with "San Francisco" (on inital loading of the table without any user interaction).

I tried a lot of the suggested solutions from the forum here and on StackOverflow - but to no success ...

Misaligned rows in Fixed columns when scrolling Y

$
0
0

I used datatables fixed columns but on load my rows are not aligned. At first it was a tiny bit misaligned but as I scroll, the row misalignment becomes more and more misaligned.

On load this is what it looks like (note: the first two columns are the fixed columns)
1st photo
then if I scroll vertically at the bottom notice that the rows are not aligned at all
2nd photo

Multi select filter with changing data

$
0
0

Hi everyone

There a jsfiddle : https://jsfiddle.net/zkugnpq5/2/
First, I used this method : https://datatables.net/release-datatables/examples/api/multi_filter_select.html
In a certain cell, I got a dropdown list (select). I actually get the multi_filter_select search to works for those dropdown list (so it display the selected option) using this :

    $.fn.dataTableExt.ofnSearch['html-input'] = function(value) {
        return $(value).val();
    };
    columnDefs: [
            { "type": "html-input", "targets": [specialSearchIndex] }
    ],

My problem is when another option is chosen, it will still display it in the search box. Worse than that, when you search again in the multi_select_filter it will display the last selected value. So it changes in the DOM but not for the DataTable.
I know there is a system that have to kind of reload the datatable if it changes, so I used this :

    table.cell().invalidate().draw();

but it didn't work

How could I achieve that ?
thanx for help

Would DataTables prevent custom modals to be shown?

$
0
0

Hi all,

I've implemented DataTables and I really love it, but is it possible that DataTables DOM manipulation causes my custom modals not to be shown after clicking a button?

I have Delete buttons which trigger custom modal display and prevent default actions until the user decides.
When landing on the page these work, but after pagination or filtering these actions are not triggered. The records simply gets deleted, which is really dangerous.

Am I doing something wrong?

thank you.
seba

Hide field in table and form

$
0
0

Hi,

I need some fields from a table to caculate KPIs and show them as fieldInfo, but I don't want to show the fields in the table and in the forms as well.

I only find this both examples "Data shown only in the form" and "Data shown in table only" where you can hide it in the form or the table.

Is the an atribute ála readonly or hide for form fields?

Thanks for any support

Cheers Patrick

One Search button for two categories

$
0
0

Hi,

I have different categories in my table and I want to implement one search button to show two categories (of 5).

Actually I use this code:
{ text: 'Purchased', action: function ( e, dt, node, config ) { var table = $('#sites').DataTable(); table.columns( 1 ).search( "Purchased" ).draw(); } },{ text: 'Sold', action: function ( e, dt, node, config ) { var table = $('#sites').DataTable(); table.columns( 1 ).search( "Sold" ).draw(); } }

And I tried to change it into this (which doesn't work also with enabled regex):
{ text: 'Purchased or Sold', action: function ( e, dt, node, config ) { var table = $('#sites').DataTable(); table.columns( 1 ).search( "Purchased|Sold" ).draw(); } }

Have anybody an idea to merge the to buttons without changing the categories?

Thanks in advance

Patrick

Search isn't working on column with text input and checkbox

$
0
0

Hey all,
in my table i have a column with two input fields, a text-field and a checkbox and i want to search for the values in the text-fields. The search function ist not working on this column, as soon as i remove the checkbox from the column, everything is fine.
Has anyone an idea how to solve this problem, i'm stuck!
Thanks Frank


export button - 'save as type'

$
0
0

hello all.
when i use export button, i want it to be selected by itself.
In Chrome, it is 'csv files(.csv)' when i use csv export button. but in IE, fundamentally, it is 'all files(.)', then I can remove its extension. i hate that.
What can i do for it??

p.s. 'extend' 'extension' option is used already.

Editor - split a database column data into two editor fields

$
0
0

I have a database column, "start", defined as type DATETIME.

In the editor I would like to split "start" into two editor fields, date and time, so I can use separate "pickers".

Likewise, once created/edited I would like to combine the date and time editor fields back into the database column "start".

I would like the date in "MM/DD/YYYY" format and time in "hh:mm a" format.

Being a bit new to Datatables and Editor, I'm not sure where to start..

Any examples would be welcome.

Regards,
Jim

Getting id when deleting a row in Editor

$
0
0

Hi all
I'm using Datatables Editor and when deleting a row I would like to get the id of the row that was deleted. In the table, I have a user_id for each row. I thought maybe the callback would work, like this

editor.on( 'remove', function ( e, json, data ) {
        //  get data.user_id and do something with it
    } );

But that doesn't do anything except it says data is undefined. Is it even possible to the user_id for the row that was just deleted?

Thanks

using a bootstrap dropdown button for the datatable.buttons

$
0
0

Is it possible to add the datatable buttons( print, csv, copy etc) to a bootstrap dropdown button?

I have tried several ways and just can't seem to figure it out. Does anybody know of any example code implementing this which i could use and modify?

Thank you.

How to alert if ajax response is empty

$
0
0

I had such good luck last time that I thought I'd try again.

I'm working on trying to add some extra validation and /or errors into my page. While it is unlikely, there is a fringe case where the Ajax query that is used to populate my datatable could return nothing. ( "[]" ). In such cases this results in the table displaying a "No data in table" message. If possible, I would like to be able to add an extra validation step that will allow me to pop an alert message to inform the user exactly what situation would've caused the no data .

I'm having a hard time figuring out where I could throw a validation check in to check the ajax response. there is no success function in the datatables ajax, and if I add one it breaks the page load. If I try adding it elsewhere in the initialization it doesn't work either or causes syntax errors.

This makes me believe that I would need to check for a no data situation once the datatable is completely initialized, but I'm not sure what the best way to do such a check is. Any help would definately be appreciated. :smile:

Viewing all 81388 articles
Browse latest View live


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