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

Things in quote, and function parameters

$
0
0

Hi,

Few obvious things but I don't have answers for it. Please bear with me. Thanks.
1. Sometimes "thing" in quote, and then sometimes not. Why? For example:

    columns: [
        {
            "className":      'details-control',
            "orderable":      false,
            "data":           null,
            "defaultContent": ''
        },
        {"data": "combo"},
        {"data": "x"},
        {
            data:   "urgent",
            render: function (data, type, row) {
                if (type === 'display') {
                    return '<input type="checkbox" class="editor-urgent">';
                }
                return data;
            },
            className: "dt-body-center"
        },
  1. Function parameters. What is available or what is the rule?
    targets: 1, render: function(row, type, val, meta) {
        ...
    render: function (data, type, row) {

Editor with array of data

$
0
0

I have a data like
person1
-contact1
-contact2
person2
-contact1

in datatable I display person as row, is there a type for array in editor? like contact field become a button to open contact editor or something to do that

Database is not getting updated

$
0
0

Hi,

I was working with datatables. The datatables got loaded successfully after getting help in the forum. I am now trying to add,edit and delete records. When I try to do that, the UI is showing the changes accordingly but the database is not getting updated.

I normally different web service calls in .net - One to get the details, another to insert/update and another to delete. Not sure how this works in Datatables/Editor.

I am new to this and I dont see many examples with server side code in .net (aspx). Most of them are with PHP / .net MVC. Please help me out with this. Please find below the code i have. I also tried to add separate web services for create/edit/remove in ajax but still not able to figure this out. Am not sure how to pass parameter to the web service calls.

Thanks!

HTML:

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="xxx.cs" Inherits="xxx" %>

<!DOCTYPE html>

<html>
<head runat="server">
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<!-- end required meta tags -->

<title>test</title>



<link href="../DataTables/Bootstrap-3.3.7/css/bootstrap.css" rel="stylesheet" type="text/css" /><!-- Do not edit -->
<link href="../DataTables/Bootstrap-3.3.7/css/bootstrap-theme.css" rel="stylesheet" type="text/css" /><!-- Define theme changes here. -->
<link href="../DataTables/DataTables-1.10.13/css/dataTables.bootstrap.css" rel="stylesheet" type="text/css" />
<link href="../DataTables/Buttons-1.2.4/css/buttons.bootstrap.css" rel="stylesheet" type="text/css" />
<link href="../DataTables/Select-1.2.0/css/select.bootstrap.css" rel="stylesheet" type="text/css" />
<link href="../DataTables/Editor-1.6.1/css/editor.bootstrap.css" rel="stylesheet" type="text/css" />
<link href="../Styles/test.css" rel="stylesheet" type="text/css" />



<script src="../DataTables/datatables.min.js" type="text/javascript"></script>
<script src="../Scripts/test.js" type="text/javascript"></script>
<!-- End JavaScript Includes -->

</head>
<body>

test

col1 col2 col3 col4 col5

</body>

</html>

Javascript:
(function () {

var editor;


$(document).ready(function () {


    editor = new $.fn.dataTable.Editor({
        ajax: {
        url: "URL to web service",
        contentType: "application/json; charset=utf-8",
        dataType: "json" },
        table: "#Grid-01",
 idSrc: "Id",
        fields: [

        {
        "label": "col 1",
        "name": "col1"
    },
        {
            "label": "col 2",
            "name": "col2"
        },
        {
            "label": "col 3",
            "name": "col3"
        },
        {
            "label": "col 4",
            "name": "col4"
        },
        {
            "label": "col 5",
            "name": "col5"
        }

    ],
    formOptions: {
        inline: {
            onBlur: 'submit'             }
    }
});

$('#Grid-01').DataTable({
    dom: "Bfrtip",
    order: [[1, 'asc']],
    ajax: {
        url: "URL to web service",
        contentType: "application/json; charset=utf-8",
        dataType: "json",
        type: "POST",
        dataSrc: function (json) {
            return JSON.parse(json.d);
    }
    },
    columns: [

{
data: null,
defaultContent: '',
className: 'select-checkbox',
orderable: false

}

                    { "data": "col1" },
                    { "data": " col2" },
                    { "data": " col3" },
                    { "data": " col4" },
                    { "data": " col5" }
        ],
 select: {
        style: 'os',
        selector: 'td:first-child'
     },
     buttons: [
        { extend: "create", editor: editor },
        { extend: "edit", editor: editor },
        { extend: "remove", editor: editor }
        ]
        });



$('#Grid-01').on('click', 'tbody td:not(:first-child)', function (e) {
    editor.inline(this);
});

});

} ());

DB Web Service

[WebMethod]
[ScriptMethod(ResponseFormat = ResponseFormat.Json)]
public string GetdataFunction()
{
string Get = string.Empty;
try
{
using (var db = new DBLookupEntities(Globals.Instance.getdbconnstring()))
{
var me = (from m in db.table1
join d in db.table2 on m.table1id equals d.table2id
select new {

                      id= m.id

col1 = m.col1,
col2= m.col2,
col3= m.col3,
col4= m.col4,
col5= d.col5

                  }).ToList();

        if (me != null)

            Get = JsonConvert.SerializeObject(me);
    }
}
catch (Exception ex)
{
    var error = ex.ToString();

}
return Get;

}

Output of DB web service(value in variable):

{"d":"[{\"col1\":\"12345\",\"col2\":\"123\",\"col3\":\"123\",\"col4\":\"100\",\"col5\":\"test_1]"}

I think I am missing the web services for insert/update/delete but so far all the examples i have seen are in php and don't have explicit call for webservice for the update/delete operations.

Thanks!

How to use Datatables jQuery UI datetime picker outside of the table.

$
0
0

Good Afternoon Allen, Everyone,

First, I just want to say I absolutely LOVE DataTables. The software is superb and the documentation, examples, community and forums are second to none! I have finally run into an issue that I can't figure out with your samples and docs, however.

I am building a CRM for our office using DataTables as it's backbone. This is on a LAMP server with MySQL.

Please see here for a working copy:
http://harborhouse.com/seawayCRM/admin.php

My issue is this. I want to use the same date/time picker that is used by DataTables in the Entry Date column bubble edit (scroll all the way to the right) outside of the table. And click on any cell in the Entry Date column.

Specifically, I want to be able to use that same picker to populate the Date, Start Date, and End Date fields you will see if you Click the "Filter Button" at the top, but instead I just get the standard jQuery UI datepicker.

I'm adding these to the text inputs with the following in the Table instantiation:

"fnInitComplete": function(oSettings, json) {
// Add datepickers to the date filter fields.
    $( "#quick_filter_date" ).datepicker({
        dateFormat: "mm-dd-yy"
    });
    $( "#quick_filter_start_date" ).datepicker({
        dateFormat: "mm-dd-yy"
    });
   $( "#quick_filter_end_date" ).datepicker({
        dateFormat: "mm-dd-yy"
   });
}

Is there a way to call the same pickers used in the bubble edit for the Entry Date field, but used outside of the table? I'd like my datepickers to match.

Now, I could just go get the datetime plugin separately, and then style it the same, but I feel like I'd be loading the jQuery UI datepicker plugin twice if I do it that way.

I'm sure this is something obvious I'm just missing, but changing .datepicker above to .datetimepicker throws an error and I'm reasonably sure calling these in the fnInitComplete function should ensure they are called after the Datatables bundled itself is called. (In addition to this code being called in the foot when the Datatables stack is all called in the head)

Thank you for your time!

Custom sql query for a field...

$
0
0

Gotten pretty far into the project and everything runs smooth.
I came across one thing though:
Is there an easy way to use a custom "SELECT COUNT(xxx) FROM table WHERE value = xxx" and return this to the client? This field is only to show how many rows that exist in another table with that special value... This field will not be updated or created. Like this for example: If Ihave 3 tables here, authors, genres and authorgenreconn(this is used to bind author and genre together since one author can have many genres), But in other fields I want to show how many books each author has, both total and in different genres.
So I would need something like:
Field::inst(SELECT COUNT(book_id) FROM books where author_id = authors.author_id)
and for example
Field::inst(SELECT COUNT(book_id) FROM books where author_id = authors.author_id AND genre_id = xxx)

Editor::inst( $db, 'authors', 'author_id' )
    ->field(
        Field::inst( 'authors.author_name' ),
        Field::inst( 'authors.author_added_date' ),
        Field::inst( 'authors.authorstatus_id' )
            ->options( 'authorstatus', 'authorstatus_id', 'authorstatus_name' ),
        Field::inst( 'authorstatus.authorstatus_name' ),
        Field::inst( 'authorstatus.authorstatus_label' )
            ->set (false)
    )
    ->leftJoin( 'authorstatus', 'authorstatus.authorstatus_id', '=', 'authors.authorstatus_id' )
    ->join(
        Mjoin::inst( 'genres' )
            ->link( 'authors.author_id', 'authorgenreconn.author_id' )
            ->link( 'genres.genre_id', 'authorgenreconn.genre_id' )
            ->order( 'genre_name asc' )
            ->fields(
                Field::inst( 'genre_id' )
                    ->options( 'genres', 'genre_id', 'genre_name' ),
                Field::inst( 'genre_name' )
            )
    )
    ->process($_POST)
    ->json();

Help with the DataTables.sln sample project

$
0
0

I am having problems getting the example .sln file to work properly.
I have successfully added my DB connection which is sql server.
However, I keep getting code errors in query.cs which I have not modified.

anyone else had this problem in the past or currently and could offer any help?

Thanks,

Is possible a "Show" button in the Editor that show fields in read-only mode?

$
0
0

Hi,
Is posible to configure editor to show a 4th button "Show" so when clicked shows all fields in a form-like interface but only to read all fields values?

For example, I show 4 fields in the table, but the user want to see all 10 fields, and I don't want to add the extra 6 columns

Thanks in advance.

Alfredo.

How can I get the value of a file type field with datatable?

$
0
0

Hi, I'm trying to get the value of a file type field embedded within the rows of datatables.

$('#dtables').DataTable({
"lengthMenu": [[5, 10], [5, 10]],
"data":[{"Tipo":"RFC","Obligatorio":"SI","nombrearchivo":"archivo1","id":"1","Verificararchivo":"si" ,"status":"aprobado"}, {"Tipo":"Curp","Obligatorio":"No","nombrearchivo":"archivo2","id":"2","Verificararchivo":"no","status":"rechazado" }, {"Tipo":"ReciboCFE","Obligatorio":"SI","nombrearchivo":"archivo3","id":"3","Verificararchivo":"no","status":"rechazado" }],
"columns": [
{"width": "10%", "data": "Tipo"},
{"width": "40%", "data": "Obligatorio"},
{"width": "40%", "data": "nombrearchivo"},
{"width": "40%", "data": "id"},
{"width": "40%", "data": "Verificararchivo"},
{"width": "40%", "data": "status"},
{
data: null,
className: "center",
render: function(){
return '\<input type="file" />';
}
}
]
});

To obtain the data I use the following

$('#dtables tbody').off().on('click', 'tr', function (e) {
var dtables = $("#dtables").DataTable();
var fila = $(this).closest('tr');
var column_data = $(fila).children('td').parents('tr');

var Tipo = dtables.row(column_data).data()["Tipo"];
var Obligatorio = dtables.row(column_data).data()["Obligatorio"];
var nombrearchivo = dtables.row(column_data).data()["nombrearchivo"];
var id = dtables.row(column_data).data()["id"];
var Verificararchivo = dtables.row(column_data).data()["Verificararchivo"];
var idpersona = dtables.row(column_data).data()["idpersona"];
var files = dtables.row(column_data).$('input[type=file]')[0].files[0];

alert( files);

});

But I can not get the data (file) that corresponds to the row that is selected with the click event on the line. How can I solve get the value of field file when selecting the row to which I have clicked?


How to display any loading symbol while export to excel or pdf process is running?

$
0
0

Datatables Export to pdf and excel takes long time....
Is their any way that we can show a loading symbol while this process is going on?

Datatable Conflict with js

$
0
0

can u please help me this problem.
i have a template, but if i use datatable is not working, in other template work. js problem.
thanks

How to License DataTables Editor

$
0
0

Hi Support,
I have purchased Editor and suddenly stop working. Is there any License key which to be required to Add in application .
Please let me know process after purchase .

Regards.
Sunil

column filtering sort

ColumnFilterWidgets choose all options

$
0
0

Is it possiblie to choose all options from dropdown menu of ColumnFilterWidgets by one click and get list of all values?

I need this function to, then I choose all values, exclude options that I don't need.

For example, I have column "country" and I want choose all country except of USA. I click "select all" and then remove USA from list.

Use "HTML5, Flash export button" function. 1000 rows export is very slow ...

$
0
0

Hello everyone!

I am migrating "C / S" programs in Korea using "DataTables".

I'm using Google Translator to ask a question.
Thank you for your understanding.

I am trying "TEST" hard now ...

Https://datatables.net/extensions/buttons/examples/html5/simple.html
Https://datatables.net/extensions/buttons/examples/flash/simple.html

I created an "export" function using the two functions above.

But,

Little rows "export" are fine, but ...

More than 1000 rows takes considerable time.

I want to get some advice on this part.


First, my development environment

  1. The latest version of "DataTables" related plug-ins.
  2. Spring, ibatis, oracle, java 1.8
  3. IE 11, Chrome 55.0.2883.87 m (64-bit)
  4. ajax
    Etc

(Let me know if I have more information)


Second, the "DataTables" script

Https://datatables.net/extensions/scroller/examples/initialisation/large_js_source.html

Using the above functions


Function fn_search () {
    
    Var parm1 = $ ("# srchParm1"). Val ();
    
    If (parm1 == null || parm1 == "") {
        Alert ("Please select parm1");
        Return;
    }
    
    $ .ajax ({
        Type: "POST",
        DataType: "json",
        Async: false,
        Url: "/listTest.json",
        Data: {
            Parm1: parm1,
            },
        Success: function (data) {
            Var items = [];
            
            $ .each (data.listTest, function (idx, item) {
                Var row = idx + 1;
                
                Items.push ([
                            Row,
                            Item.name,
                            Item.telNo
                ]);
            });
            DoMasterInsertData (items);
        },
        Error: function (request, status) {
            Return;
        }
    });
}
 
Function doMasterInsertData (data) {
    $ ("# MasterTable"). DataTable ({
        "Buttons": ['excelFlash'], //Or 'excelHtml5'
        "AutoWidth": true,
        "Destroy": true,
        "Data": data,
        "ScrollX": true,
        "ScrollY": "70%",
        "ScrollCollapse": false,
        "Paging": true,
        "PagingType": "simple_numbers",
        "Info": false,
        "Searching": false,
        "Dom": '<"top"> rt <"bottom" Bflp> <"clear">'
        "DeferRender": true,
        & Quot; lengthMenu & quot ;: [[20, 30, 50, 100], [20, 30, 50, 100]
        "Columns": [
                {ClassName: "grid_data_c"},
                {ClassName: "grid_data_c"}
            ]
        "Language": {
            "EmptyTable": "Data does not exist.",
            "LengthMenu": "maximum bar MENU",
            "Paginate": {
                "First": "First",
                "Last": "last",
                "Next": "Next",
                "Previous": "previous"
            }
        },
        "InitComplete": function (settings, json) {
            CommonObj.innerInputBind ("masterTable");
              CommonObj.innerSelectBind ("masterTable");
              CommonObj.gridResizeId ("masterTable");
              SetTimeout (function () {commonObj.gridOrder ("masterTable", [0, "asc"]);
         },
         "FooterCallback": function () {
             Var api = this.api ();
             If (api.data (). Length> 0) {
                 $ (Api.column (0) .footer ()). Html (api.data (). Length.money () + "key");
             }
         }
     });

}

Separately call "ajax" and draw "DataTables".

By doing this,

Is the export speed slower, of course?

If so, change the script as shown below

Is it possible to solve it?

Https://datatables.net/extensions/scroller/examples/initialisation/server-side_processing.html

I'll change the ajax call in the DataTables until the answer comes up

I'm sorry I could not include the js example.

Thank you for reading.

DataTables Editor Table not showing Select Labels but Value instead

$
0
0

Hello volks,

i've just got the editor licence and i'm struggeling to get my table showing the information i want it to.
The first screenshot shows my current table, second shows the edit select field.

I want to have the label of the selected value from the DB in the table by default not the value.
I do also have a readonly field which has options defined which is also only showing the value not label.

**Status **should display the label of the current status in the table (shows int) and select on edit (this works)
**Type **should display the label and does not need to be edited

here is my js:

var editor; // use a global for the submit and return data rendering in the examples
var table; // use global for table

$(document).ready(function() {

    editor = new $.fn.dataTable.Editor( {
        ajax: {
            url: 'libs/basic/datatables/orderposition.php',
            data: {
                "collectiveinvoice": 141
            }
        },
        table: "#datatable",
        fields: [
            {
                label: "Status:",
                name: "status",
                type: "select"
            },
            {
                label: "Beschreibung:",
                name: "comment",
                type: "ckeditor",
                opts: {
                    toolbarGroups: [
                        { name: 'forms', groups: [ 'forms' ] },
                        { name: 'editing', groups: [ 'find', 'selection', 'spellchecker', 'editing' ] },
                        { name: 'document', groups: [ 'mode', 'document', 'doctools' ] },
                        { name: 'clipboard', groups: [ 'clipboard', 'undo' ] },
                        { name: 'basicstyles', groups: [ 'basicstyles', 'cleanup' ] },
                        { name: 'paragraph', groups: [ 'list', 'indent', 'blocks', 'align', 'bidi', 'paragraph' ] },
                        { name: 'links', groups: [ 'links' ] },
                        { name: 'insert', groups: [ 'insert' ] },
                        { name: 'styles', groups: [ 'styles' ] },
                        { name: 'colors', groups: [ 'colors' ] },
                        { name: 'tools', groups: [ 'tools' ] },
                        { name: 'others', groups: [ 'others' ] },
                        { name: 'about', groups: [ 'about' ] }
                    ],
                    removeButtons: 'Source,Save,Templates,NewPage,Preview,Print,Cut,Copy,Paste,PasteText,PasteFromWord,Find,SelectAll,Scayt,Replace,Form,Checkbox,TextField,Radio,Textarea,Select,Button,ImageButton,HiddenField,Subscript,Superscript,CreateDiv,BidiLtr,BidiRtl,Language,Anchor,Image,Flash,Smiley,SpecialChar,Iframe,Font,About,Maximize'
                }
            }, {
                label: "Menge:",
                name: "quantity"
            }, {
                label: "Preis:",
                name: "price"
            }, {
                label: "Steuer:",
                name: "tax",
                type: "select"
            }
        ]
    } );
    // Disable KeyTable while the main editing form is open
    editor
        .on( 'open', function () {
            table.keys.disable();
        } )
        .on( 'close', function () {
            table.keys.enable();
        } );

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


    table = $('#datatable').DataTable( {
        dom: "<'row'<'col-sm-4'l><'col-sm-4'B><'col-sm-4'f>><'row'<'col-sm-12'tr>><'row'<'col-sm-5'i><'col-sm-7'p>>",
        ajax: {
            url: 'libs/basic/datatables/orderposition.php',
            data: {
                "collectiveinvoice": 141
            }
        },
        order: [[ 1, 'asc' ]],
        columns: [
            { data: "id" },
            { data: "type" },
            { data: "status" },
            { data: "comment" },
            { data: "quantity" },
            { data: "price" },
            { data: "tax" }
        ],
        select: false,
        buttons: [
            // Export Button
            {
                extend: 'collection',
                text: 'Export',
                buttons: [
                    'copy',
                    'excel',
                    'csv',
                    'pdf',
                    'print'
                ]
            },
        ]
    } );
} );

here is server side php:

Editor::inst( $db, 'collectiveinvoice_orderposition' )
    ->where( 'status', 0, '>' )
    ->where( 'collectiveinvoice', $_REQUEST['collectiveinvoice'] )
    ->fields(
        Field::inst( 'id' )->set(false)->validator( 'Validate::unique' )->validator( 'Validate::numeric' ),
        Field::inst( 'status' )->options( function () {
            return array(
                array( 'value' => '0', 'label' => 'gelöscht' ),
                array( 'value' => '1', 'label' => 'aktiv' ),
                array( 'value' => '2', 'label' => 'deaktiviert' ),
            );
        }),
        Field::inst( 'quantity' )
            ->validator( 'Validate::numeric' )
            ->getFormatter( 'Format::toDecimalChar' )
            ->setFormatter( 'Format::fromDecimalChar' ),
        Field::inst( 'price' )
            ->validator( 'Validate::numeric' )
            ->getFormatter( 'Format::toDecimalChar' )
            ->setFormatter( 'Format::fromDecimalChar' ),
        Field::inst( 'tax' )->options( Options::inst()
            ->table( 'taxkeys' )
            ->value( 'value' )
            ->label( 'value' )
        ),
        Field::inst( 'comment' ),
        Field::inst( 'type' )->set(false)->options( function () {
            return array(
                array( 'value' => '0', 'label' => 'Manuell' ),
                array( 'value' => '1', 'label' => 'Artikel (Kalk)' ),
                array( 'value' => '2', 'label' => 'Artikel' ),
                array( 'value' => '3', 'label' => 'Perso' ),
            );
        }),
        Field::inst( 'file_attach' )->set(false),
        Field::inst( 'perso_order' )->set(false)
    )
    ->process( $_POST )
    ->json();

In addition, i want to display buttons based on the DB values of "file_attach" and "perso_order" so that they only show and have a reference in them to the db field, how would one do that? Or in other words how do i add a custom field to the table anyways (which is readonly)?

Thanks for this great tool!

Regards


Initcomplete not working well on multiple tables

$
0
0

as i am saying on the title when i am using init of datatables more then once the each table has been initialized the select of all the tables gets the data from last table

            initComplete : function () {
                this.api().column(1).every(function(){
                    var column = this;
                    var select = $('<select class="form-control input-sm"><option value="">All</option></select>')
                        .appendTo( $('.filter_data2').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>' )
                    } );
                });

            }

HTML 5 data-sort does not work

$
0
0

I'm trying to use HTML5 data-sort attribute on a table that's rendered from PHP, after hours of debugging i've found the culprit it's the "columns: {}" option i have on my datatables instance, however i need that for my inline editor, my code looks something like this

`
$(document).ready(function() {

    var dtable = $('.data.table').DataTable({
      columns: <?php echo $tableColumns; ?>,
      columnDefs: [
        {targets: 'no-sort', orderable: false}
      ],
      order: [],
      responsive: true,
      keys: {
          columns: ':not(.no-inline-edit)',
          editor:  editor,
          keys: [ 9 ]
      }
    });

    var editor = new $.fn.dataTable.Editor({
      ajax: function(method, url, data, onSuccess, onError) {

        var formData = {};
        formData['inlineAjax'] = 1;
        formData['tableName'] = '<?php echo htmlencode($tableName) ?>';
        $.each(data['data'], function(index, value) {
          formData['recordNum'] = index;
          $.each(value, function(i, v) {
            formData['fieldName'] = i;
            formData['value'] = v;
          });
        });

        var edfields = <?php echo $editorColumns; ?>;
        var edrow = {};
        $.each($("tr#"+formData['recordNum']+" td"), function(index, value) {
          edrow[edfields[index]['name']] = $(value).html();
        });
        formData['row'] = edrow;

        $.ajax({
          'type': 'POST',
          'url': "<?php echo $_SERVER['REQUEST_URI']; ?>",
          'data': formData,
          'dataType': 'json',
          'cache': false,
          success: function(json) {
            onSuccess(json);
          },
          error: function (xhr, error, thrown) {
            onError(xhr, error, thrown);
          }
        });

      },
      table: '.data.table',
      fields: <?php echo $editorColumns; ?>,
      formOptions: {
          inline: {
              onBlur: 'submit'
          }
      }
    });

    dtable.on('key-focus', function(e, datatable, cell) {

      $(document).on('focus', '.data.table > tbody > tr > td.focus', function(e) {
        var cellVal = $('.data.table .focus').data('value');
        $('.data.table .focus').find('input').val(cellVal);
      });

      if($(datatable.cell(cell.index()).nodes()).data('inlinetype') == "bubble") {
        editor.bubble(cell.index());
      } else {
        editor.inline(cell.index());
      }

    });

`

if i comment the "columns:{}" in my datatables instance then the sort works fine, but the inline editor does not work anymore, is there way to make it work ?

Thanks,
Claudiu

Datetime field not showing error message from server

$
0
0

Hi! I'm running into an issue where I'm sending down an error message in the fieldErrors array in json to a datetime field, but the only text displaying in the editor-datetime-error div is 'Error'.

It's finding the correct field and setting an error, but the message doesn't seem to be inserted. Any ideas on what I might be doing wrong?

Refreshing Datatable in real time and showing a automatic popup based on cell value threshold

$
0
0

Hi,

I have a scenario where I need to refresh the data after every 5secs based on data ingested in backend database. Then i need to show a popup on top of datatable itself if any of the value crossed the threshold limit.

I am able to highlight the cell values using this piece of code
"createdRow": function ( row, data, index ) {
if ( data["col1"] > 40000 ) {
$('td', row).eq(0).addClass('highlight');

                }
            },

But not sure how to show an automatic popup in datatable. Is there any feature in datatable for this kind of scenarios?

Thanks in Advance.

Regards,
Vipul

DataTable Pipeline Failed to load resource: the server responded with a status of 400 (Bad Request)

$
0
0

Please find below the jquery functions that I have customized for my requirement ,

$.fn.dataTable.pipeline = function ( opts ) {
// Configuration options

var conf = $.extend( {
    pages:10,
    //pages: 10,     // number of pages to cache
    url: '',      // script url
    data: null,   // function or object with parameters to send to the server
                  // matching how `ajax.data` works in DataTables
    method: 'POST' // Ajax HTTP method

}, opts );

console.log(conf.data);

// Private variables for storing the cache
var cacheLower = -1;
var cacheUpper = null;
var cacheLastRequest = null;
var cacheLastJson = null;

return function ( request, drawCallback, settings ) {

    console.log(request);
    var ajax          = false;
    var requestStart  = request.start;
    var drawStart     = request.start;
    var requestLength = request.length;
    var requestEnd    = requestStart + requestLength;

    if ( settings.clearCache ) {
        // API requested that the cache be cleared
        alert("ajax true first");
        ajax = true;
        settings.clearCache = false;
    }
    else if ( cacheLower < 0 || requestStart < cacheLower || requestEnd > cacheUpper ) {
        // outside cached data - need to make a request
        ajax = true;
        alert("ajax true seccond");
    }
    else if ( JSON.stringify( request.order )   !== JSON.stringify( cacheLastRequest.order ) ||
              JSON.stringify( request.columns ) !== JSON.stringify( cacheLastRequest.columns ) ||
              JSON.stringify( request.search )  !== JSON.stringify( cacheLastRequest.search )
    ) {
        // properties changed (ordering, columns, searching)
        alert("ajax true third");
        ajax = true;
    }

    // Store the request for checking next time around
    cacheLastRequest = $.extend( true, {}, request );

    if ( ajax ) {
        // Need data from the server
        if ( requestStart < cacheLower ) {
            requestStart = requestStart - (requestLength*(conf.pages-1));

            if ( requestStart < 0 ) {
                requestStart = 0;
            }
        }

        cacheLower = requestStart;
        cacheUpper = requestStart + (requestLength * conf.pages);

        request.start = requestStart;
        request.length = requestLength*conf.pages;

        // Provide the same `data` options as DataTables.

        console.log(conf.data);
        if ( $.isFunction ( conf.data ) ) {
            // As a function it is executed with the data object as an arg
            // for manipulation. If an object is returned, it is used as the
            // data object to submit
            alert("first condition");
            var d = conf.data( request );
            if ( d ) {
                $.extend( request, d );
            }
        }
        else if ( $.isPlainObject( conf.data ) ) {
            alert("second condition");
            // As an object, the data given extends the default
            $.extend( request, conf.data );
        }

                settings.jqXHR = $.ajax( {
                    "type":     conf.method,
                    "url":      conf.url+'?'+$.param(request),
                    "data":     JSON.stringify(conf.data),
                    "processData": false,
                     "contentType" : "application/json",
                    /* "dataType": "json", */
                    "cache":    false,
                    "success":  function ( json ) {

                cacheLastJson = $.extend(true, {}, json);

                if ( cacheLower != drawStart ) {
                    json.data.splice( 0, drawStart-cacheLower );
                }
                if ( requestLength >= -1 ) {
                    json.data.splice( requestLength, json.data.length );
                }

                drawCallback( json );
            }
        } );
    }
    else {
        json = $.extend( true, {}, cacheLastJson );
        json.draw = request.draw; // Update the echo for each response
        json.data.splice( 0, requestStart-cacheLower );
        json.data.splice( requestLength, json.data.length );

        drawCallback(json);
    }
}

};

// Register an API method that will empty the pipelined data, forcing an Ajax
// fetch on the next draw (i.e. table.clearPipeline().draw())
$.fn.dataTable.Api.register( 'clearPipeline()', function () {
return this.iterator( 'table', function ( settings ) {
settings.clearCache = true;
} );
} );

javascript code for DataTable Initialization ,

str='{"tableName":"table_name","fromDate":"'+frmDateDrillDown+'","toDate":"'+toDateDrillDown+'","draw":"0","start":"0"}';

$('#popupGridTableRaw').DataTable( {
"processing": true,
"serverSide": true,
"bLengthChange": false,
"pageLength": 100,
"searching": false,
"ordering": false,
columns : [ {
"data" : "arafImsi"
},
{
"data" : "arafMsisdn"
},
{
"data" : "arafIccid"
},
{
"data" : "arafSubStatus"
},
{
"data" : "arafSubStsRsnCd"
},
{
"data" : "arafSubType"
},
{
"data" : "arafMarket"
},
{
"data" : "arafSubmkt"
},
{
"data" : "arafFilterInd"
},
{
"data" : "arafDuplicateInd"
},
{
"data" : "arafTimestamp"
},

    ],
    "ajax": $.fn.dataTable.pipeline( {

         type:"POST",
        url:"${hostConfig.applicationUrl}/rawDataBucket",
        data:str,

         dataType: "json",
        async: true,
        crossDomain: true,
        pages: 10 // number of pages to cache
    } )
} );

Kindly help me in resolving this issue. Thanks in advance.

Viewing all 81384 articles
Browse latest View live


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