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

Bug in `Join.php`

$
0
0

This code in Join.php (line 691)

                ->where_group( function ( $q ) use ( $that ) {
                    $q->or_where( $that->_join['child'], $ids );
                } );

gives an error. $ids should also be part of the use clause.


Error when using autoFill().disable()

No text in header row & header text appears at end of datatable...?

$
0
0

Anyone come across this situation before? The header text appears mixed in with the data - the header text even sorts properly within the data, as if it is data. The sort widgets appear in the header row, but no text...

TIA

Custom filtering with slider range

$
0
0

Hello everybody!

I am trying to make a custom filtering with slider range.
Custom filtering is that : https://datatables.net/examples/plug-ins/range_filtering.html

I have 2 input "min" and "max", the function to filter and the event listener exactly as shown in the example.

But I would like to have a slider to do that.
I tried to modify the "min" and "max" with the slider function (shown bellow) but this only modify "min" and "max" without applying the filter. I guess it is a problem with the listener that is "keyup" but I cannot find a solution to this.

And then I would like to have two sliders and checkboxes with options (but this is maybe another story)

Thank you very much,

//Slider function
$( function() {
    $( "#slider-range" ).slider({
      range: true,
      min: 0,
      max: 70,
      values: [ 0, 70 ],
      slide: function( event, ui ) {
       $( "#min" ).val(ui.values[ 0 ]);
     $( "#max" ).val(ui.values[ 1 ]);
      }
    });
  } );
//Example functions
$.fn.dataTable.ext.search.push(
    function( settings, data, dataIndex ) {
        var min = parseInt( $('#min').val(), 10 );
        var max = parseInt( $('#max').val(), 10 );
        var age = parseFloat( data[3] ) || 0; // use data for the age column

        if ( ( isNaN( min ) && isNaN( max ) ) ||
             ( isNaN( min ) && age <= max ) ||
             ( min <= age   && isNaN( max ) ) ||
             ( min <= age   && age <= max ) )
        {
            return true;
        }
        return false;
    }
);

$(document).ready(function() {
    var table = $('#example').DataTable();

    // Event listener to the two range filtering inputs to redraw on input
    $('#min, #max').keyup( function() {
        table.draw();
    } );
} );

How to format date returned from .NET ajax call.

$
0
0

Here's my client-side code:

                var url = "@Url.Action("GetDisplayMessagesDataTables", "Admin", new {locId = "__locId__"})";
                var locId = $("#displayselect option:selected")[0].value;
                url = url.replace("__locId__", locId);

                editor = new $.fn.dataTable.Editor( {
                    ajax: { url,
                        data: function (d) {
                            if (d.action == "create")
                                d.data[0].DisplayLocation_ID = $("#displayselect option:selected")[0].value;
                        }
                    },
                    table: "#messagegrid",
                    fields: [{
                        label: "Message Index:",
                        name: "MessageIndex"
                    }, {
                        label: "Message Text:",
                        name: "MessageText",
                    }, {
                        label: "Expiration:",
                        name: "Expiration",
                        type: "datetime",
                        def: "",
                        format: "MM-DD-YYYY hh:mm A",
                        fieldInfo: "mm-dd-yyyy hh:mm am/pm"
                    }],
                    formOptions: {
                        inline: {
                            onBlur: 'submit'
                        }
                    }
                } );

                $('#messagegrid').DataTable({
                    dom: "Bfrtip",
                    destroy: true,
                    ajax: url,
                    columns: [
                        { data: "MessageIndex" },
                        { data: "MessageText" },
                        { data: "Expiration" }
                    ],
                    select: true,
                    buttons: [
                        { extend: "create", editor: editor },
                        { extend: "edit", editor: editor },
                        { extend: "remove", editor: editor }
                    ]
                })
            });

Server-side code:

        public JsonResult GetDisplayMessagesDataTables(int locId) {
            var formData = HttpContext.Request.Form;
            using (var db = new Database("sqlserver", ConfigurationManager.ConnectionStrings["MjnDisplaysConnectionString"].ConnectionString)) {
                Field f = new Field("DisplayMessage_ID").Set(false);

                Field ex = new Field("Expiration")
                    .SetFormatter((obj, data) => {
                        if (obj != null && (string)obj != "") {
                            DateTime dt;
                            if (DateTime.TryParse(obj.ToString(), out dt))
                                return dt;
                            else
                                return null;
                        } else
                            return null;
                    })
                    .GetFormatter((obj, data) => {
                        string ret = null;
                        if (obj != null) {
                            DateTime dt = (DateTime)obj;
                            ret = dt.ToString("MM-dd-yyyy hh:mm tt");
                        }

                        return ret;
                    });

                var response = new Editor(db, "DisplayMessage", "DisplayMessage_ID")
                    .Model<DisplayMessageData>()
                    .Where("DisplayLocation_ID", locId)
                    .Field(f)
                    .Field(ex)
                    .Field(new Field("MessageText").Xss(false))
                    .Process(formData)
                    .Data();

                return Json(response, JsonRequestBehavior.AllowGet);
            }
        }

Expiration is my datetime database field and it always displays as a JSON date (i.e. /Date(1434253400000) in the data table. I've looked through the Date/Time examples but don't see where anything special is done as far as formatting on the client side.

What am I missing?

Thanks,
Dave

Editor1.6 bug with php5.3&JS

$
0
0

in practise, it seems that there are several bugs with editor 1.6

  1. The following code, xhr.responseJSON seems to be empty when submitting row update data. (chrome). did I missing some important depency?
Editor.prototype._ajax = function ( data, success, error )
{
    var thrown;
    var opts = {
        type:     'POST',
        dataType: 'json',
        data:     null,
        error:    [ function ( xhr, text, err ) {
            thrown = err;
        } ],
        complete: [ function ( xhr, text ) {
            // Use `complete` rather than `success` so that all status codes are
            // caught and can return valid JSON (useful when working with REST
            // services).
            var json = xhr.status === 204 ?
                {} :
                xhr.responseJSON;

2 . server side, PHP5.3, for example, [_ssp_field] is a private class method. But PHP 5.3 do not allow a anonymous function with [use (that)] to access private members of [that] (which is actually that = this) . This leads to several problems.
One of the most important problem is , when a query condition is actually a callback function, in Query::xxx_where_xxx methods it just cannot access to [Join::_join] which is a private member field, so finally a "delete from where 1=1" will be generated. This happened in our production environments and made me so sad :(

For some reasons it is difficult for us to update php version, so I'm so happy to find a library like Datatables declared supporting php5.3.

Please test editor with php 5.3 as strictly as with php5.5+, thank you very much!

GET data in datatable serverside processing

$
0
0

Can I use GET method in datatable serverside processing? I want to use GET instead of POST method.

Thanks,
Mack

Using entire width( when scrolling is on) for DataTables

$
0
0

Hi :),
please take a look at my screenshot -> http://pasteboard.co/i3JDiTBEm.png .

I am using the latest version of datatables.

Relevant code snippet:

           scrollX: false,
        scrollY: "20vh",
        scrollCollapse: true,
        //responsive: true,
        responsive: {
            details: false
        },

Is there a way to use the entire width of the header plus the peace of the scroll bar's width ?

Thanks in advance.


Sorting icons are visible even when sortable is set to false

$
0
0

Version: 1.10.13

If a column is sorted with e.g. { order: [ 0, 'asc'] ] } and the column is defined with { sortable: false, targets: 0 }, then the sorting icons are still displayed for this column. This also happens when no initial order is given at all.

If another column is sortable and the sorting icon is clicked, then the sorting icon of the non-sortable column disappears.

Urgent Using Colvis with save state and indiviual column search on top creates issue.?

Sorting icon in data tables

$
0
0

I have a table in which i am using Data Tables functionality for sorting the columns. Is is possible to just have one sorting image which changes to the upper triangle and lower triangle onclick. I donot want 2 triangles sorting icon. Please suggest.

Thanks

Make Search look for extended characters

$
0
0

I have values in a column that contain extended characters, like 'ä' and 'ö'. When searching, I would like to include those in the results when the search string just has 'a' and 'o'.

E.g. the cell has the string 'bröd'. When the search string is 'bro', this row should be included in the results.

Page Size, Export Button, Search box needed

$
0
0

I want all three option together ( page size, export button { multiple options }, search box ).Is it possible? and if possible then how?

datatable colvis individual columns searching conflict

$
0
0

Hello my friends, i need your help, actualy am trying to use datatable Colvis option with individual columns searching: till now every thing is working great Except when i use to colvis option to hide a column, it's work But the input search box don't get hide
The Code:

is "https://cdn.datatables.net/1.10.13/js/jquery.dataTables.min.js" is having any dependency???

$
0
0

i am getting error(Uncaught TypeError: undefined is not a function ) on this line "register=p=function(a,b){if(h.isArray(a))for(var " .
referening is not a function.
support me with the possible solution.


Validate Unique if numeric, and not unique when value is "EXTRA"

$
0
0

Hi, here's a tough one for you:

I have a field which normally is numeric and must be unique when it is. But, on some occasions the user can create a record where the field value is set to "EXTRA".
Is it possible to validate:
1. Unique if it's a number.
2. If it's not a number the string must be exactly "EXTRA". But the value EXTRA needn't be unique.

I mean the Editor validation on the pphp side...

integration colvis button and responsive extension

$
0
0

Hi all.
In my use of datatable, I need the colvis button (to manage columns visibility) and the responsive extension (because I have a lot of colomns in my table).
I noticed that, completly randomly, when I toggle some colomns visibility (for example I hide then re-show the same colomn without closing the modal colomn selection view), some colomns are suddently colopsed under the + responsive item (but it is not normal , they shouldn't be, because they were not in the begining).

If someone knows how to correct this behaviour , I would be grateful.

I noticed that when recharging the page (after chosing my coloms visibility through the colvis button), the responsive extension acted back normaly. I had then the idea the reload the window (window.location.reload();) after the closure of the colvis modal window (colomn selection), but I don't know how I can do that without affecting the normal behaviour of the colvis button. If I put an action option, that will take place of the normal behaviour of the colvis button. And I don't know how to call the original behaviour of the colvis button inside an action option.
I would think of something like that :

{
    extend: 'colvis',
    action: function ( e, dt, node, config ) {
         <here call the default behaviour of the colvis button> <== I don't know how to do that. If someone can help me. Thanks.
         window.location.reload();
    }
}

Thank you for your help

Datatable Select Tag

$
0
0

I have created one select type column for each row in datatable. Here userTypeList is an array in which I added some datas. When the datatable is loaded the value is not populated in select type datas.

vm.dataTableInstance = $('.datatable-basic').DataTable({
data : userList,
columns : [
{ data: 'fname', title : 'First name', width: '10%' },
{ data: 'lname', title : 'Last Name', width: '5%' },
{ data: null, title : 'User Type', width: '5%',render:function(data,type,row){
return '<select data-placeholder="Select a type" id="userTypeSelect" class="select" ><option>'+userTypeList+'</option></select>';
}}
],
order: [0, "asc"],
bPaginate : false,
rowReorder: {
selector: 'td:nth-child(2)'
},
});

How to emulate page maximize behaviour

$
0
0

Hi,

I have an issue where occassionally a table's column headers fail to correctly align with the columns in the table body. I'm using the same code to produce many tables accross many pages, and it works fine say 98% of the time.

What always fixes this is if I restore and then maximize the browser window (frustratingly, this is also fixed if I have the developer console open in either FireFox or Chrome - not currently seeing this issue in IE). So I was wondering if I could have a JS call after rendering each table that would have the same effect as a browser restore/maximize?

I already have a call to columns.adjust().draw() after each table to fix another issue (similar I believe, I forget now), so might there be a similar "fix"? Or has anyone come across this exact issue and can suggest anything else?

I have to apologise and say that I've been unabke to reproduce this with bare-bones code, and the present example isn't publicly accessible. Sorry.

Row doesn't change after update

$
0
0

Hello,

i have a problem that i cannot solce. After i update a row cell, its value remains the same and the row does not update at all.

the editor is declared as such:

editor = new $.fn.dataTable.Editor( {
table: "#events",
ajax: "/api/events",
legacyAjax: true,
formOptions: {
bubble: {
submit: 'all'
}
},
fields: [{
name: "time", type: "hidden"
},{
label: "<?=tr('Punti casa')?>", name: "hs", type: "score"
},{
label: "<?=tr('Punti trasferta')?>", name: "vs", type: "score"
},{
label: "<?=tr('Giocatore')?>", name: "player.value", type: "select", options: people
},{
label: "<?=tr('Squadra')?>", name: "disp_name.value", type: "select", options: teams
},{
label: "<?=tr('Fondamentale')?>", name: "skill.value", type: "select", options: skills
},{
label: "<?=tr('Valutazione')?>", name: "mark.value", type: "select", options: marks
},{
label: "<?=tr('Tipo')?>", name: "type.value", type: "select", options: type
},{
label: "<?=tr('Posizione')?>", name: "pos", type: "number"
},{
label: "<?=tr('Pos. palleggiatore')?>", name: "setter_pos", type: "number"
},{
label: "<?=tr('Pos. palleggiatore avv.')?>", name: "opp_setter_pos", type: "number"
}
]
});

the response json is:

{ "data":[
{"DT_RowId":"13641","hteam_id":"42","vteam_id":"38","time":"18:13:02","set_number":"4","player"
:{"label":"2-Schiacciatore","value":"457"},"player_id":"457","homescore":"0","visitorscore":"1","skill"
:{"label":"Difesa","value":"2"},"mark":{"label":"=","value":"6"},"type":{"label":"-","value":0},"pos"
:"6","setter_pos":"1","opp_setter_pos":"6","disp_name":{"label":"i Termosifoni","value":"42"},"team_id"
:"42","hs":"0","vs":"1"}]
}

editor version is v1.6.1

Viewing all 81903 articles
Browse latest View live