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

How to change 2nd select box when 1st selectbox change?

$
0
0

I am trying to change the value of my second select box when my first select box change?

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

$(document).ready(function() {
    editor = new $.fn.dataTable.Editor( {
        ajax: "insert.php",
        table: "#example",
        fields: [ {
                label: "Item Name:",
                name: "fs_items.name"
            }, {
                label: "Price:",
                name: "fs_items.price"
            }, {
                label: "Description:",
                name: "fs_items.description",
                type: "textarea"
            },{
                label: "Category:",
                name: "fs_items.main_categoryid",
                type: "select",
                placeholder: "Select a Category"
            },{
                label: "Category:",
                name: "fs_items.sub_categoryid",
                type: "select",
                placeholder: "Select a Category"
            },{
                label: "Image:",
                name: "fs_items.image",
                type: "upload",
                display: function ( file_id ) {
                    return '<img src="'+table.file( 'fs_files', file_id ).web_path+'"/>';
                },
                clearText: "Clear",
                noImageText: 'No image'
            }
        ]
    } );

     // New record
    $('a.editor_create').on('click', function (e) {
        e.preventDefault();

        editor.create( {
            title: 'Create new record',
            buttons: 'Add'
        } );
    } );

     // Edit record
    $('#example').on('click', 'a.editor_edit', function (e) {
        e.preventDefault();

        editor.edit( $(this).closest('tr'), {
            title: 'Edit record',
            buttons: 'Update'
        } );
    } );

    // Remove a record
    $('#example').on('click', 'a.editor_remove', function (e) {
        e.preventDefault();

        editor.edit( $(this).closest('tr'), {
            title: 'Remove record',
            message: 'Are you sure you wish to remove this record?',
            buttons: 'Remove'
        }).hide()
        .set( 'status', 'deactive' );
    } );


    var table = $('#example').DataTable( {
        ajax: "insert.php",
        dom: 'Bfrtip',
        columns: [
            { data: "fs_items.name" },
            { data: "fs_items.price", render: $.fn.dataTable.render.number( ',', '.', 0, '₱' ) },
            { data: "fs_items.description" },
            { data: "fs_main_categories.name" },
            { data: "fs_sub_categories.name" },

            {
                data: "fs_items.image",
                render: function ( file_id ) {
                    return file_id ?
                        '<img src="'+table.file( 'fs_files', file_id ).web_path+'"/>' :
                        null;
                },
                defaultContent: "No image",
                title: "Image"
            },
            { data: "fs_items.userid" },
            { data: "fs_items.create_date" },
            { data: "fs_items.update_date" },
            {
                data: null,
                className: "center",
                defaultContent: '<a href="" class="editor_edit">Edit</a> / <a href="" class="editor_remove">Delete</a>'
            }
        ],
        buttons: [
            'copyHtml5',
            'excelHtml5',
            'csvHtml5',
            'pdfHtml5'
        ]
    } );
} );
Editor::inst( $db, 'fs_items' )
    ->fields(
        Field::inst( 'fs_items.name' )
            ->validator( 'Validate::notEmpty' )
            ->validator( 'Validate::unique' ),
        Field::inst( 'fs_items.price' )
            ->validator( 'Validate::notEmpty' )
            ->validator( 'Validate::numeric' )
            ->setFormatter( 'Format::ifEmpty', null ),
        Field::inst( 'fs_items.description' )
            ->validator( 'Validate::notEmpty' ),

        Field::inst( 'fs_items.main_categoryid' )
            ->options( 'fs_main_categories', 'id', 'name' )
            ->validator( 'Validate::dbValues' ),
        Field::inst( 'fs_main_categories.name' ),

        Field::inst( 'fs_items.sub_categoryid' )
            ->options( 'fs_sub_categories', 'id', 'name' )
            ->validator( 'Validate::dbValues' ),
        Field::inst( 'fs_sub_categories.name' ),

        Field::inst( 'fs_items.image' )
            ->validator( 'Validate::notEmpty' )
            ->setFormatter( 'Format::ifEmpty', null )
            ->upload( Upload::inst( $_SERVER['DOCUMENT_ROOT'].'/upload/__ID__.__EXTN__' )
                ->db( 'fs_files', 'id', array(
                    'filename'    => Upload::DB_FILE_NAME,
                    'filesize'    => Upload::DB_FILE_SIZE,
                    'web_path'    => Upload::DB_WEB_PATH,
                    'system_path' => Upload::DB_SYSTEM_PATH
                ) )
                ->validator( function ( $file ) {
                    return$file['size'] >= 50000 ?
                        "Files must be smaller than 50K" :
                        null;
                } )
                ->allowedExtensions( [ 'png', 'jpg', 'gif' ], "Please upload an image" )
            ),
        Field::inst( 'fs_items.userid' )
        ,
        Field::inst( 'fs_items.create_date' )
        ->getFormatter( 'Format::date_sql_to_format', Format::DATE_ISO_8601 )
        ->setFormatter( 'Format::date_format_to_sql', Format::DATE_ISO_8601)
        ,
        Field::inst( 'fs_items.update_date' )
        ->getFormatter( 'Format::date_sql_to_format', Format::DATE_ISO_8601 )
        ->setFormatter( 'Format::date_format_to_sql', Format::DATE_ISO_8601)

    )
    ->leftJoin( 'fs_main_categories', 'fs_main_categories.id', '=', 'fs_items.main_categoryid' )
    ->leftJoin( 'fs_sub_categories', 'fs_items.main_categoryid', '=', 'fs_sub_categories.main_categoryid' )
    ->where( function ( $q ) {
    $q->where( 'fs_items.status','' , '=' );
} )
    ->process( $_POST )
    ->json();

Edited by Allan - Syntax highlighting. Details on how to highlight code using markdown can be found in this guide.


How to count the json data before loading the datables

$
0
0

Hi ,
How to count the records in datatables before loading . Below is my datatables

var Table;
function displayDataTable() {
Table= $('#example').DataTable(
{
"ajax": {
"url": '@Url.Action("Search", "Home")',
"dataSrc": "",
"dataType": "json",
},
"dom": '<"row"<"col-xs-6"f><"col-xs-6 text-right toolbar">>rt<"row"<i><l><"col-xs-12"p>>',
"pagingType": "simple_numbers",

"columns": [

{ "data": "CashId" },
{ "data": "PaymentType" },
{ "data": "Amount" },
{ "data": "PhoneNumber" },
{ "data": "Name" },
],
"columnDefs": [

            { orderable: false, targets: 5 }
    ],
    "order": [[1, 'desc']],
});

}

Refresh ajax grid not working

$
0
0

I have a page that I'm working on using asp.net mvc core. The page includes a datatables grid populated with an ajax source. This is working as expected. I click a button to bring up a semantic ui modal to add a new entry. This is also working as expected and the new item is added to the database.

On the success handler for the form post I want to refresh the grid. The success handler is being hit as I have verified that with an alert box. Here is the ajax call.

<script type="text/javascript">
function submitForm() {
    $.ajax({
        url: "/Division/CreateTableGroup",
        type: "POST",
        data: $("form").serialize(),
        success: function(data){
            $("#table_group_list").DataTable().ajax.reload();
        },
        error: function (response) {
            alert("error")
        }
    });
}
</script>

Any idea why the reload might not be happening?

How to pass an Ajax URL with params inside a ajax.url() method?

$
0
0

Hi guys,

I'm trying to change the url of an existing table and load it. How can I pass params in this ajax.url method?

I wanna do somethig like this:

var oTable;

$(function(){

        oTable = $('.sortable').DataTable({
            bRetrieve: true,
            bProcessing: true,
                    bServerSide: true,
                   ajax: 'my_url.php',
                   sPaginationType: 'full_numbers',

            });

        $("#my_checkbox").change(function(){
             //Wanna use my new url and params here
                     contratosTable.ajax.url(new_url, params).load();
        });
});

Thanks for attention!

How i get all data in the table help

$
0
0

Hello, I'm trying to get all the data in a table,
but so monent I have not been able

for example i have this table

 <thead>
            <tr>
                <th>Name</th>
                <th>Position</th>
                <th>Office</th>
                <th>Age</th>
                <th>Start date</th>
                <th>Salary</th>
            </tr>
        </thead>
<tbody>
            <tr>
                <td>Tiger Nixon</td>
                <td>System Architect</td>
                <td>Edinburgh</td>
                <td>61</td>
                <td>2011/04/25</td>
                <td>$320,800</td>
            </tr>
<tr>
                <td>Garrett Winters</td>
                <td>Accountant</td>
                <td>Tokyo</td>
                <td>63</td>
                <td>2011/07/25</td>
                <td>$170,750</td>
            </tr>
</tbody>

i need get all data foreach row

1 row ->{Tiger Nixon,System Architect,Edinburgh,61,2011/04/25,$320,800}
2 row->{Garrett Winters,Accountant....................etc etc}

I'm testing with this code

$("#tblCatalogoActualModal td").each(function(index) {
                $(this).parents("tr").find("td").each(function(){/*metodo para recorrer la tabla*/
                      alert($(this).html());
                    switch($(this).parent().children().index($(this))) {//obtengo el index de la columna EKISDE
                        case 0:
                            codigo = $(this).html();
                            break;
                        case 1:
                            articulo = $(this).html();
                            break;
                        case 2:
                            break;
                        case 3:
                            puntos = $(this).html();
                            break;
                        case 5:
                            break;
                        default:
                        //alert($(this).html());
                    }
                });
                alert("out");
            /*var form_data = {
                codigo: codigo,
                puntos: puntos,
                articulo: articulo,
                IdCatalogo: IdCatalogo
                };
             $.ajax({
                url: "actualizarCatalogo",
                type: "post",
                async:true,
                data: form_data,
                success:
                    function(json){
                        Materialize.toast('SE GUARDARON LOS CAMBIOS EN EL CATALOGO, ESPERE..', 3000);
                        var myVar = setInterval(myTimer, 2000);
                    }
                });*/
            });

Color of Selected Row

$
0
0

How do I change color of selected row?
I searched but could not find it :)
I also tried this but it doesn't work.
I need a hint. Thanks!

"fnRowCallback": function(nRow, aData, iDisplayIndex, iDisplayIndexFull) {
  if ($(nRow).hasClass("selected")) $(nRow).css('color', 'white');
  // if ($(nRow).hasClass("active")) $(nRow).css('color', 'white');
},

Trouble with data Ajax call

$
0
0

Hello,
I am trying to bind a datatable to data acquired via an ajax call, but the ajax call always returns an empty array.
However, a direct call to the data with a jquery ajax call returns the data successfully.

Here is my code:

<html>
    <head>
        <link rel="stylesheet" href="https://cdn.datatables.net/1.10.12/css/jquery.dataTables.min.css">
        <script src="//code.jquery.com/jquery-1.12.3.js"></script>
        <script src="https://cdn.datatables.net/1.10.12/js/jquery.dataTables.min.js"></script>
        <script>

            var jsonData;
            $.ajax({
                url: "https://api.domain.com/group/",
                type: 'GET',
                success: function(data, textStatus, jqXHR)
                {
                    console.log(data); //*** returns correct json data
                }
            });

            $(document).ready(function() {
                $('#example').DataTable( {
                    "ajax": {
                        "url": "https://api.domain.com/group/",
                        "type": "GET",
                        "dataSrc":"",
                        "complete": function(xhr, responseText){
                            console.log(xhr);
                            console.log(responseText); //*** responseJSON: Array[0]
                        }
                    }
                } );
            } );

        </script>
    </head>
    <body>
        <table id="example" class="display" cellspacing="0" width="100%">
            <thead>
                <tr>
                    <th>name</th>
                    <th>description</th>
                    <th>createdAt</th>
                    <th>updatedAt</th>
                    <th>id</th>
                </tr>
            </thead>
            <tfoot>
                <tr>
                    <th>name</th>
                    <th>description</th>
                    <th>createdAt</th>
                    <th>updatedAt</th>
                    <th>id</th>
                </tr>
            </tfoot>
        </table>
    </body>
</html>

Here is the json returned by the jquery ajax call:

[
  {
    "experiments": [
      {
        "name": "Animation",
        "description": "test",
        "group": 1,
        "createdAt": "2015-10-22T02:10:53.691Z",
        "updatedAt": "2015-11-08T03:41:08.173Z",
        "id": 2,
        "build_number": "1.a.0032",
        "url": "experiments/svg/saves.svg"
      },
      {
        "name": "Technical Drawing",
        "description": "test",
        "group": 1,
        "createdAt": "2015-10-31T22:39:31.374Z",
        "updatedAt": "2015-11-08T04:05:46.258Z",
        "id": 3,
        "build_number": "1.a.0033",
        "url": "experiments/svg/vacumatic.svg"
      },
      {
        "name": "KeySpline Animation",
        "description": "test",
        "group": 1,
        "url": "experiments/svg/escapement.html",
        "build_number": "1.a.0034",
        "createdAt": "2015-11-08T04:09:56.049Z",
        "updatedAt": "2015-11-08T04:09:56.049Z",
        "id": 4
      }
    ],
    "name": "SVG (Scalable Vector Graphics)",
    "description": "SVG animation tests.",
    "createdAt": "2015-10-22T02:05:02.156Z",
    "updatedAt": "2015-11-08T03:08:32.662Z",
    "id": 1
  },
  {
    "experiments": [
      {
        "name": "Sails JS",
        "description": "Building a restful api with Sails JS",
        "group": 2,
        "url": "https://api.jptrue.com",
        "build_number": "1.a.0035",
        "createdAt": "2015-11-10T03:04:31.383Z",
        "updatedAt": "2015-11-10T03:22:03.192Z",
        "id": 6
      }
    ],
    "name": "API (Application Program Interface)",
    "description": "API tests.",
    "createdAt": "2015-10-22T02:06:55.339Z",
    "updatedAt": "2015-11-08T03:09:39.163Z",
    "id": 2
  },
  {
    "experiments": [
      {
        "name": "Dynamically generated alerts",
        "description": "test",
        "group": 3,
        "url": "experiments/bootstrap/alert.html",
        "build_number": "1.a.0035",
        "createdAt": "2015-11-08T04:40:56.812Z",
        "updatedAt": "2015-11-08T04:40:56.812Z",
        "id": 5
      }
    ],
    "name": "Bootstrap",
    "description": "Scalable Vector Graphics",
    "createdAt": "2015-10-31T22:38:50.180Z",
    "updatedAt": "2015-11-08T04:39:37.239Z",
    "id": 3
  }
]

Any help is greatly appreciated!

Thanks,
Jeff

Does datatables will accept alert function?But i found it not works?

$
0
0

I had used the following part of code to display popup?Is anything i missed or i want add in the following alert part?

print "\$(\'#placeholder28-table tbody tr\').on(\'click\',\'td:nt-child(10)\',function(f){ ^M \n";
alert('Data:'+$(this).html().child());
alert('Row:'+$(this).parent().find('td').html().child());
alert('Column:'+$('#placeholder thead tr th').eq($(this).index()).html().child());
print "});\n";
print "});\n";


Data exists in the table, but the table displays ' no data available in table'

$
0
0

https://debug.datatables.net/esumox

While updating the checkboxes in column 1, very rarely all the data completely disappears and nets me 'No data available in table' message, which is strange because its not even my set message.

"oLanguage": { "emptyTable": "No data available in table, try changing your options or refresh your browser if the problem continues.", "sEmptyTable": "No data available in table, try changing your options or refresh your browser if the problem continues." }

What scenario would it bypass this and go back to the default? I'm not familiar with dataTables enough to understand what causes this issue.

looking at the debug log, the data is in there, yet the full table state notes the table's are empty?

Any help would be appreciated.

disable( [ fieldName ] ) posting data regardless

$
0
0

I've a multi-row editor with the following checkbox (+ other fields)...
fields: [{name: 'InvoiceOutbound.approval', label:'Approval', type:'checkbox', options: {'': 1}}]

Within the initEdit Editor event I need to disable that editor field depending on circumstance...
editor.disable(['InvoiceOutbound.approval']);

On a multi-row edit action the server is receiving the data as if the fields had not been disabled as would have happened in a normal HTTP form post. Within the editing form itself the fields are disabled to the User as expected, but the Ajax post of data (assumed to be disabled) causes issues as the field is included in the post and means further processing at Server. Is this anticipated behaviour?

action:edit
data[1][InvoiceOutbound][approval][]:1
data[2][InvoiceOutbound][approval][]:1

How to filter the content of a select box in the editor form?

$
0
0

Hello,

I would like to know if there is a way to actually filter the content being loaded into a "select box" in the editor form.
Let's have a look at this example: https://editor.datatables.net/examples/simple/join.html.
The sites, db table has the "id" and "name" fields.
Question: Is it possible to only load the city names starting with "L" in the "Sites" select box? If yes, could you please tell me how to do it? My guess is adding a "where" clause on the "name" field, but for some reason I have only managed to filter the content of my table, not the content of the select box.

Thanks a lot and cheers for a great product!

Parse Error upload function

$
0
0

I have problem with the Upload Functions of the Editor. I get this error and I have no idea what I do wrong.

<b>Parse error</b>:  syntax error, unexpected ''i_pdf'' (T_CONSTANT_ENCAPSED_STRING), expecting ')' in <b>C:\xampp7\htdocs\finswimming\assets\lib\evm_server_processing.php</b> on line <b>101</b><br />

I want upload some files (pdf, lxf, zip) and the Information about the files should stored in a extra table, like your example. I have no idea where my fault is.

Andreas

php


if((include 'confic.inc') == FALSE){ echo 'Failed include config'; } if((include PLUGIN_DIR.'DTables/Editor/1.5.6/php/DataTables.php') == FALSE){ echo 'Failed include Edit'; } use DataTables\Editor, DataTables\Editor\Field, DataTables\Editor\Format, DataTables\Editor\Mjoin, DataTables\Editor\Upload, DataTables\Editor\Validate; $db->sql( 'CREATE TABLE IF NOT EXISTS `ltv_events` ( `id` INT UNSIGNED NOT NULL AUTO_INCREMENT , `federation` VARCHAR(255) NOT NULL, `b_date` DATE NOT NULL , `e_date` DATE NOT NULL , `deadline` DATE NOT NULL , `m_title` VARCHAR(255) NOT NULL , `m_course` VARCHAR(5) NOT NULL , `m_street_1` VARCHAR(255) NOT NULL , `m_street_2` VARCHAR(255) NOT NULL , `m_zip` VARCHAR(10) NOT NULL , `m_city` VARCHAR(255) NOT NULL , `m_nation` VARCHAR(5) NOT NULL , PRIMARY KEY (`id`)) ENGINE = InnoDB CHARACTER SET utf8 COLLATE utf8_unicode_ci;' ); $FormattoSQL = 'd. F Y'; $SQLtoFormat = 'd. F Y'; $store_year = date('Y'); Editor::inst( $db, 'ltv_events', 'id' ) ->fields( Field::inst( 'ltv_events.id' ), Field::inst( 'ltv_events.b_date' ) ->validator( 'Validate::dateFormat', array( 'empty' => false, 'format' => $FormattoSQL )) ->getFormatter( function ($val, $data, $opts ){ if($val === '0000-00-00'){ return NULL; } else{ return date( 'd. F Y', strtotime( $val )); } } ) ->setFormatter( 'Format::date_format_to_sql', $FormattoSQL ), Field::inst( 'ltv_events.e_date' ) ->validator( 'Validate::dateFormat', array( 'empty' => false, 'format' => $FormattoSQL )) ->getFormatter( function ($val, $data, $opts ){ if($val === '0000-00-00'){ return NULL; } else{ return date( 'd. F Y', strtotime( $val )); } } ) ->setFormatter( 'Format::date_format_to_sql', $FormattoSQL ), Field::inst('ltv_events.deadline') ->validator( 'Validate::dateFormat', array( 'format' => $FormattoSQL )) ->getFormatter( function ($val, $data, $opts ){ if($val === '0000-00-00'){ return NULL; } else{ return date( 'd. F Y', strtotime( $val )); } } ) ->setFormatter( 'Format::date_format_to_sql', $FormattoSQL ), Field::inst( 'ltv_events.m_title' ) ->validator( 'Validate::notEmpty') ->validator( 'Validate::minLen', 2 ), Field::inst( 'ltv_events.m_course' )->validator( 'Validate::notEmpty' ), Field::inst( 'ltv_events.m_street_1' ), Field::inst( 'ltv_events.m_street_2' ), Field::inst( 'ltv_events.m_zip' ), Field::inst( 'ltv_events.m_city' ), Field::inst( 'ltv_events.m_nation' ) ->options('nation_codes', 'IOC', 'name_en') ->validator( 'Validate::dbValues' ), Field::inst( 'nation_codes.name_en' ), Field::inst( 'nation_codes.ISO3166-1-Alpha-2 as ISO3166' ), Field::inst( 'ltv_events.federation' ), Field::inst( 'ltv_events.id', 'ltvid') ->getFormatter( function ($val, $data, $opts ){ return 'row_'.$val; }), Field::inst( 'ltv_events_files.i_pdf' ) ->options( 'ltv_events_files', 'id', 'i_pdf') ->validator( 'Validate::dbValues' ) ->upload( Upload::inst( $_SERVER['DOCUMENT_ROOT'].'/'.PROJECT_DIR.'/ltv_events/'.$store_year ) ->db( 'ltv_events_files', 'id', array(                 'i_pdf' => Upload::DB_FILE_NAME,                 'i_pdf_file_size' => Upload::DB_FILE_SIZE, 'i_pdf_date' => date('Y-m-d H:i:s') ) ) ->setFormatter( 'Format::nullEmpty' ) ->allowedExtensions( array( 'pdf' ), "Please upload an pdf file") ) ) ->leftJoin('nation_codes', 'nation_codes.IOC', '=', 'ltv_events.m_nation') ->leftJoin('ltv_events_files', 'ltv_events_files.id', '=', 'ltv_events.files') ->process( $_POST ) ->json();

JS:


edit_mlist = new $.fn.dataTable.Editor({ ajax: 'assets/lib/evm_server_processing.php', table: '#meetlist', display: 'bootstrap', fields: [{ label: 'Event Title:', name: 'ltv_events.m_title' },{ type: 'datetime', label: 'Start Date:', name: 'ltv_events.b_date', format: 'DD. MMMM YYYY' },{ type: 'datetime', label: 'End Date:', name: 'ltv_events.e_date', format: 'DD. MMMM YYYY' },{ type: 'datetime', label: 'Deadline:', name: 'ltv_events.deadline', format: 'DD. MMMM YYYY' },{ label: 'Course:', name: 'ltv_events.m_course', type: 'radio', options: [ '50m', '25m'], def: '50m', fieldInfo: '' },{ label: 'Street:', name: 'ltv_events.m_street_1' },{ label: '', name: 'ltv_events.m_street_2' },{ label: 'ZIP:', name: 'ltv_events.m_zip' },{ label: 'City:', name: 'ltv_events.m_city' },{ label: 'Nation:', name: 'ltv_events.m_nation', type: 'select', def: 'AUT' },{ label: 'Invation PDF:', name: 'ltv_events_files.i_pdf', type: 'upload', display: function ( id ) { return editor.file( 'images', id ); } } ] });

1.10.13?

$
0
0

I remember reading awhile back this was going to be released soon (I believe it was a discussion about jquery 3 and some of the changes made). Seems like it has been awhile since then - at least a month or more, but I could be wrong. When is this projected?

Was working (in entire window), when .load() ed into a DIV, it fails

$
0
0

Uncaught TypeError: $(...).DataTable is not a function

New to this, but I had it working before I 'fixed' the target.

I HAD relied on (but it was failing) HTML5's data-target="center_body" to place the page/table into desired DIV.

When I added the $('#center_body').load('the url', function....
it now fails to load DataTable() with the error pasted above.

Where do I look next?

Thanks!

sa: https://jsfiddle.net/RSmithBothell/z0kg8v0w/

How to join a table on two conditions?

$
0
0

I see that the leftJoin function takes the four parameters:

leftJoin( 'view_data_points', 'data_reporting_manual.data_point_id', '=', 'view_data_points.data_point_id' )

This can produce something like:

INNER JOIN data_reporting_manual ON data_reporting_manual.data_point_id = view_data_points.data_point_id

However what I'm trying to do is that last JOIN with the AND. How can I do this?

SELECT
view_data_points.short_name,
view_data_points.data_point_id,
data_reporting_manual.data_date,
data_reporting_manual.data_value,
data_reporting.data_value as SFValue
FROM
view_data_points
INNER JOIN data_reporting_manual ON data_reporting_manual.data_point_id = view_data_points.data_point_id
INNER JOIN data_reporting ON data_reporting_manual.data_point_id = data_reporting.data_point_id AND data_reporting_manual.data_date = data_reporting.data_date

What I've tried is the following code in my ajax.php. Notice the comment //breaks to see the join that breaks things:

Editor::inst( $db, 'data_reporting_manual' )
      ->pkey( 'data_reporting_manual.data_id' )
      ->field(
          Field::inst( 'data_reporting_manual.data_date' )->validator( 'Validate::dateFormat', array(
              "format"  => Format::DATE_ISO_8601,
              "message" => "Please enter a date in the format yyyy-mm-dd"
          ) )
               ->getFormatter( 'Format::date_sql_to_format', Format::DATE_ISO_8601 )
               ->setFormatter( 'Format::date_format_to_sql', Format::DATE_ISO_8601 ),
          Field::inst( 'data_reporting_manual.data_value' ),
          Field::inst( 'view_data_points.short_name' ),
          Field::inst( 'data_reporting_manual.data_point_id' )
               ->options( 'view_data_points', 'data_point_id', 'short_name' )
      )
      ->leftJoin( 'view_data_points', 'data_reporting_manual.data_point_id', '=', 'view_data_points.data_point_id' )
    //breaks
      ->join(
        Editor\Join::inst( 'data_reporting', 'object' )->link( 'data_reporting_manual.data_point_id', 'data_reporting.data_point_id' )->link( 'data_reporting_manual.data_date', 'data_reporting.data_date' )->field(
            Field::inst( 'data_reporting.data_value' )->set( false )->name( 'sf_data_value' )
        )
    )
      ->process( $_POST )
      ->json();

Only create record fail

$
0
0

Hi,

The code below can successfully update and delete records but fail at create record

XHR return :
Fatal error: Call to a member function insertId() on null in C:\data\demo\libs\datatables\media\php\Editor\Editor.php on line 1381

http://debug.datatables.net/ivuwir

use
    DataTables\Editor,
    DataTables\Editor\Field,
    DataTables\Editor\Format,
    DataTables\Editor\Mjoin,
    DataTables\Editor\Upload,
    DataTables\Editor\Validate;

if ( $_SESSION[$website["appname"]]["menuCategoryId"]!="" ) {

    Editor::inst( $db, 'menuItem','menuItemId' )
    ->fields(
        Field::inst( 'menuItem.description' )
            ->validator( 'Validate::notEmpty' ),
        Field::inst( 'menuItem.page' ),
        Field::inst( 'menuItem.icon' ),
        Field::inst( 'menuItem.path' ),
        Field::inst( 'menuItem.menuCategoryId' )
            ->options("menuCategory","menuCategoryId","menuCategory.description"),
        Field::inst( 'menuCategory.description' ),
        Field::inst( 'menuItem.dorder' )
    )
    ->leftJoin("menuCategory","menuCategory.menuCategoryId","=","menuItem.menuCategoryId")
    ->where("menuItem.menuCategoryId",$_SESSION[$website["appname"]]["menuCategoryId"],"=")
    ->process( $_POST )
    ->json();
} else {
    $return["data"] = array();
    echo json_encode($return);
}

Please help, thx.

How to Resize a column by dragging in Datatable?

$
0
0

Hi
Is it possible to resize the column width by dragging in Datatable?
If possible, I would like to know how to use!

Thanks

Datatable Export to Excel button opening file dialog instead of direct saving on IE11

$
0
0

I am trying to implement "Export To Excel" function for Datatable using following code:
'dom': 'Bfrtip',
'buttons': [{
extend: 'excel',
text: 'Export To Excel',
filename: exportFileName,
exportOptions: { columns: ':visible' }
}]

This code works fine except one thing. It is opening file save dialog instead of downloading with new IE save file dialog (bottom of browser) it is opening classic save file dialog.

Please help me to resolve this.

Thanks in advance.

Editor: Possible bug: date picker and responsive integration

$
0
0

Hi,

Date picker open only once when It's in a child row and the field is updated.

Steps to reproduce:

  1. Open https://editor.datatables.net/examples/inline-editing/responsive.html
  2. Change the size of the browser so the start date is hidden.
  3. Open any row to show the start date column.
  4. Click over the start date field, date picker should pop up.
  5. Change the date, pulse enter to accept the change.
  6. Now try click over the same start date field.
  7. Date picker doesn't show up.

Remarks:
-If you next try on other rows the date picker still doesn't work.
-It only happens when the datetime field is updated in a child row.
-jQuery UI date picker has the same problem.

Thanks!

Invalid date with datetime-moment.js

$
0
0

Hi.

I have a databasefield with "YYYY-MM-DD" format.

In my js I have this:

$(document).ready(function() {

$.fn.dataTable.moment( 'DD.MM.YYYY' );

and in the data this:

data: "tm_mm_mitglieder.Geburtsdatum",
render: function ( data, type, row ) {
           return (moment(data).format("DD.MM.YYYY"));
    }

All is working but when the date in the database is empty or "0000-00-00" the table show "Invalid date" and the sorting is not working.

Then I have played with this:

data: "tm_mm_mitglieder.Geburtsdatum",
render: function ( data, type, row ) {
    var rowvalueallday = row["5"];

         if (rowvalueallday == '0000-00-00') {
         var gdat = '1900-01-01';
                       return gdat;
                      } else {
                         return (moment(data).format("DD.MM.YYYY"));
                      }

But it's not working.

How can I make the sort working correct and show "00.00.0000" or "Kein Datum angegeben" in the table?

Rappi

Viewing all 82314 articles
Browse latest View live