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

Conditions MJoin

$
0
0

I am trying to use a condition on the Joined table with MJoin - I do not want to show archived entries - but it does not work. What do I do wrong?

Thanks in advance!

// Build our Editor instance and process the data coming from _POST
$editor = Editor::inst($db, 'as_users', 'user_id');

########
# Joins
// für die as_user_details
$editor->leftJoin( 'as_user_details as details', 'as_users.user_id', '=', 'details.user_id' );

// as_user_roles
$editor->leftJoin('as_user_roles as roles', 'as_users.user_role', '=', 'roles.role_id');

// Join für den Namen des Users, der dein Eintrag erzeugt hat
$editor->leftJoin('as_user_details as created_details', 'as_users.created_by_user_id', '=', 'created_details.user_id');

// Join für die Qualifikationen 1:n

$editor->join(
    Mjoin::inst('qualifications_names')
        //->validator('qualifications_names[].id', Validate::mjoinMinCount(1))
        ->link('as_users.user_id', 'link_as_users__qualifications_names.user_id')
        ->link('qualifications_names.id', 'link_as_users__qualifications_names.qualification_names_id')
        // TODO archivierte nicht anzeigen
        //->order('name asc')
        ->fields(
            Field::inst('id')
                ->set(Field::SET_NONE)
                ->validator(Validate::required())
                ->options(Options::inst()
                    ->table('qualifications_names')
                    ->value('id')
                    ->label('qualification_name'),
                Field::inst('qualification_name')
                )
        )
        ->where("qualifications_names.archived", "1", "!=")
);

Are there any examples of using datatables editor with django application?

$
0
0

In particular, Django REST framework. I have not problem getting data into the datatable however cannot get the editor buttons to work ("create", "edit", "delete"). At this stage I'm only using the trial editor package to see if suitable, does this have restrictions that prevent these functions?

Datatables Editor and Scala (Playframework)

$
0
0

Has anyone built a grid with datatable editor in Scala (Playframework)?
or in case you've come across one, please share the link?

Default date in hidden input field

$
0
0

Hi

I am trying to implement a date field (named Reg_date in the MySQL database) for Datatables Editor. The problem I am facing is to get this field to, first of all, be hidden, which I achieve by:

type: "hidden",

and secondly to default to the current date, which is done by:

"def": function () {
return new Date();
},

but, seeing that I have the filed type as "hidden", I cannot assign the type as "DateTime" as well, or I simply don't know how to.

Here is my PHP as well:

Field::inst( 'Reg_date' )
->validator('Validate::dateFormat', 'd-m-Y')
->getFormatter('Format::date_sql_to_format', 'd-m-Y')
->setFormatter('Format::date_format_to_sql', 'd-m-Y'),

The field must NOT update when editing a record as this field is used as the registration date for the member.

! This is for an existing database with date fields stored by the client as e.g. 31.08.05 which would translate to 31 Oct 2005.

Default date in hidden input field

$
0
0

Hi

I am trying to implement a date field (named Reg_date in the MySQL database) for Datatables Editor. The problem I am facing is to get this field to, first of all, be hidden, which I achieve by:

type: "hidden",

and secondly to default to the current date, which is done by:

"def": function () {
return new Date();
},

but, seeing that I have the filed type as "hidden", I cannot assign the type as "DateTime" as well, or I simply don't know how to.

Here is my PHP as well:

Field::inst( 'Reg_date' )
->validator('Validate::dateFormat', 'd-m-Y')
->getFormatter('Format::date_sql_to_format', 'd-m-Y')
->setFormatter('Format::date_format_to_sql', 'd-m-Y'),

The field must NOT update when editing a record as this field is used as the registration date for the member.

! This is for an existing database with date fields stored by the client as e.g. 31.08.05 which would translate to 31 Oct 2005.

index or variable not found in preCreate

$
0
0

I keep this error coming:

Undefined variable: filter in D:\website\studio\test_debiteuren\php\table.datatables_demo.php on line 34
{"data":[]}

If I change $filter to $_POST['dossier'] error is

Undefined index: dossier in

I have been reading several items here, but I don't see any solution.

this is php-code:

<?php

/*
 * Editor server script for DB table datatables_demo
 * Created by http://editor.datatables.net/generator
 */

// DataTables PHP library and database connection
include( "lib/DataTables.php" );

// Alias Editor classes so they are easy to use
use
    DataTables\Editor,
    DataTables\Editor\Field,
    DataTables\Editor\Format,
    DataTables\Editor\Mjoin,
    DataTables\Editor\Options,
    DataTables\Editor\Upload,
    DataTables\Editor\Validate,
    DataTables\Editor\ValidateOptions;

// Build our Editor instance and process the data coming from _POST
$filter = isset($_POST['dossier'])?$_POST['dossier']:1747;  //filter recordset according to currently selected row
Editor::inst( $db, 'datatables_demo', 'id' )
    ->fields(
        Field::inst('clientID')->set( Field::SET_CREATE ),
        Field::inst( 'first_name' ),
        Field::inst( 'last_name' ),
        Field::inst( 'position' )
    )
    ->on( 'preCreate', function ( $editor, $values ) {
        $editor
            ->field( 'clientID' )
            ->setValue($_POST['dossier']);
    })
    ->where('clientID',$filter)
    ->process( $_POST )
    ->json();

Example available on http://oostveen-advies.eu/test/datatables_demo.html

Thank you

I want to show child rows with responsive view

$
0
0

Hi all, i want to show responsive view and another child row for ajax data. I want to implement something like this https://www.datatables.net/blog/2017-03-31#Ajax-request but with a button.

I tried to add a button with a class but the button does nothing.

i'm using aoColumns to render data, and i have several links for button. My button is actually a dropdown with many links.

$('#lc_dt body').on('click', 'manMrIf', function () {
    var tr = $(this).closest('tr');
    var row = table.row( tr );

    if ( row.child.isShown() ) {
        row.child.hide();
        tr.removeClass('shown');
    }
    else {
        row.child( format(row.data()) ).show();
        tr.addClass('shown');
    }
} );

nothing happens, my table is responsive so when i click on more info it has to close responsive but that does not work, i alos add alert(1) after

$('#lc_dt body').on('click', 'manMrIf', function () {

but i cant see alert

How to Execute a PHP Script on Delete

$
0
0

Hi

I am using the DT Editor and I have some associated data on a different server that I need to delete when I delete a record.

Does DT have a hook or something that I could use to trigger a PHP script.

Kind Regards,
Adrian Smith


no data retrieved

$
0
0

Hi,

I am using a Synology NAS as a webserver.
Details:
Synology DS216 II
MariaDB 10 (Mysql database) port 3306 (default)
Apache http server 2.4
PHP7.3
PHP7.2
PHP5.6
Wordpress
Webstation
Webserver runs ok,

When I connect to the synology I use the following connection information:
Database source MySQL (online)
MySQL server 192.168.1.19
MySQL Database Briefing
MySQL Username GEZC
MySQL Password xxxxx
MySQLTable Instructeurs

After publishing the whole site to the Synology:
No errors, but no data

response is : \n";foreach($row as $cell) {echo "\n';} echo "\n";}?
Column1 Column2 Column3
".$cell."

What is wrong?
Al the connection parameters are correct I use them for another application to.
Thanks in advance

File Uploads Example

$
0
0

Hi All!
I'm building a variation on the file upload example for the Editor.

Can anyone please provide a complete working example as it is not clear to me how the data structure works.
Even just an SQL dump would be really helpful

Just wondering if it would be helpful with the examples section to include
* A zipfile of a the example including SQL dump that could be loaded on a local machine and work out of the box. Sometimes in learning - some of us! - are helped by being able to work back from something that is already working
* If a zip file is not feasible just an SQL dump could be helpful in cases like the upload example

Any comments / help much appreciated
Mike

Datatable responsive problem with Grid layout

$
0
0

I encountered display problems in Firefox when I'm using a grid layout. I created a test file where I only placed one grid element.

As you can see, it creates a horizontal scrollbar instead of hiding another column.

Even IE does it correct

You can test it yourself at
http://2019.hockeyarenas.net/DataTable.html

The "full" file is here (page still under development though) which works fine unter Chrome, but not under Firefox (IE grid not yet implemented, therefore not working on IE):
http://2019.hockeyarenas.net/?page=0300&lang=en

As you can see, the table content is too wide (wider than all the other grid elements).

Any idea how to overcome/fix this problem?

css of the test file

    @charset "utf-8";
    Body { 
        font-family: verdana, arial, helvetica, sans-serif;
    }
    .titlebar_right {
        color: white;
        margin: 0px 0px 10px 0px; 
        padding: 2px 2px 2px 2px;
        background: rgb(39,74,114);
        background: -webkit-gradient(linear, left top, right top, from(rgba(39,74,114,1)), color-stop(20%, rgba(37,75,114,1)), color-stop(50%, rgba(65,104,137,1)), color-stop(80%, rgba(37,75,114,1)), to(rgba(39,74,114,1)));
        background: -o-linear-gradient(left, rgba(39,74,114,1) 0%, rgba(37,75,114,1) 20%, rgba(65,104,137,1) 50%, rgba(37,75,114,1) 80%, rgba(39,74,114,1) 100%);
        background: linear-gradient(90deg, rgba(39,74,114,1) 0%, rgba(37,75,114,1) 20%, rgba(65,104,137,1) 50%, rgba(37,75,114,1) 80%, rgba(39,74,114,1) 100%); 
        border-radius: 4px;
    }     

    main {
        display: block;
        -ms-grid-row: 1;
        -ms-grid-column: 1;
        grid-area: content;
        background-color: white;
        border-radius: 8px;
        -webkit-box-shadow: 1px 1px 4px 0 #595959;
          box-shadow: 1px 1px 4px 0 #595959;     
        padding: 3px 0px 3px 0px;    
    }

    body {
        margin-left : 0px;
        margin-right: 2px;
        margin-bottom : 2px;
        margin-top : 0px;    
        font-size: 10px;    
    }
    
    .container {
      display: -ms-grid;
      display: grid; 

          grid-template-areas:
        "content";    

      -ms-grid-rows: auto;    

      grid-template-rows: auto; 
      -ms-grid-columns: 1fr; 
      grid-template-columns: 1fr; 
      grid-gap: 2px;

      height: 100vh;    
    }

HTML of the test file

<!DOCTYPE html>
<html>
  <head>
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />

<meta http-equiv="content-type" content="text/html;charset=utf-8">
        
<link href="inc/v4_css/style_v2_datatables_test.css" rel="stylesheet" type="text/css">
<link rel="stylesheet" type="text/css" href="https://cdn.datatables.net/1.10.19/css/jquery.dataTables.min.css">
<link rel="stylesheet" type="text/css" href="https://cdn.datatables.net/responsive/2.2.3/css/responsive.dataTables.min.css">
 <TITLE>DataTable Test</TITLE>
<script type="text/javascript" language="javascript" src="https://code.jquery.com/jquery-3.3.1.js"></script>
<script type="text/javascript" language="javascript" src="https://cdn.datatables.net/1.10.19/js/jquery.dataTables.min.js"></script>
<script type="text/javascript" language="javascript" src="https://cdn.datatables.net/responsive/2.2.3/js/dataTables.responsive.min.js"></script>
          
<script type="text/javascript">      
    $(document).ready(function() {

        $('#arenas').DataTable( {
                    aLengthMenu: [[10, 25, 50, 100], [10, 25, 50, 100]],
                    iDisplayLength: 25,
                    language: {
                        url: '/inc/DataTables/de.txt'
                    },
                    responsive: true 
                } );
    } );           
</script>                
</head>
    <body>
        <div class="container">
            <main>
                <h1 class="titlebar_right"><span class=''>Container / Main</span></h1>
                <table class='display nowrap' id='arenas' style='width: 100%;'>
                    <thead>
                        <tr>
                            <th data-priority="1">Land</th>
                            <th data-priority="1" class="word_break"><div align="left">Stadion</div></th>   
                            <th data-priority="3"><div align="left">Ort</div></th>
                            <th data-priority="4"><div align="left">Team</div></th>
                            <th data-priority="2">Kapazität</th>
                            <th>Bau</th>
                            <th></th>
                    </tr></thead><tbody>
                    <tr>
                        <td>(logo)</td>
                        <td><a href="?page=3000&arID=4362" target="_parent" >Centre Sportif Robert-Lebel</a></td>
                        <td>Chambly</td>
                        <td></td>
                        <td>
                            <div align="right">
                                1'200</div>
                        </td>
                        <td>
                            <div align="right">
                                1972</div>
                        </td>
                        <td>
                            <div align="right">
                                </div>
                        </td>
                    </tr>
                </table>
            </main>
        <div class="container">
    </body>
</html>

when i use messageTop for export pdf then showing this error

$
0
0

when use messageTop for pdf export then i face this problem anyone can solve it??

Data Tables Export Excel

$
0
0


I have a table where I used the render to place some columns with currency format. So far so good, the problem is when I try to export the table data to excel, it doesn't take the data as currency. I already figured out the reason, I can't render and want to customize the currency format of export to excel. I wish I could have the currency table and be able to export to excel in currency format. I sent a picture of how I did it.

html5 buttons export doesn't exclude the Header Colums

$
0
0

i have a dynamic dataTable function to do a export with

exportOptions: {
    columns: 'th:not(.noexportar)',
    format: {
        body: function (data, row, column, node) {
            data = jQuery('<p>' + data + '</p>').text();
            return jQuery.isNumeric(data.replace(',', '.')) ? data.replace(',', '.') : data;
        }
    }
},

But the Excel file keep the Header Column:

(POS) is the column that i dont wanna show in exports

How i can solve it?

Excel Export create multiple sheets


how do I filter out the same row in self referencing join

$
0
0

I want a drop down with all users except the current one in the row I am editing.

What do I put in the second value in the where clause below?

->table('users')
->value('id')
->label('name')
->order('name ASC')
->where(function ($r) {
  $r->where('id', ?, '!=');
})

How to reset the filters using a button?

$
0
0

How to reset the filters using a button?

Difference between bStateSave and stateSave?

$
0
0

is there any difference between bStateSave and stateSave?

Editor isn't respecting the alias in a field with an SQL function

$
0
0

I am trying to convert geometry in a PostgreSQL/PostGIS table into GeoJSON inside Editor and setting an alias for that field. In the "Getting started" documentation there is an example code (showing a MySQL function) that indicates that it's possible to use SQL functions in the fields.

The field I'm creating looks like the following:

Field::inst( 'ST_AsGeoJSON(ST_Transform(ST_Centroid(files_info.geom), 4326))', 'geometry' )
            ->getFormatter( function($val, $data, $opts) { return json_decode($val, true); } ) // server to client
            ->set(Field::SET_NONE),

However, Editor doesn't see the alias in a field with a function.

Using Editor's debug() mode, I can inspect the SQL that it's generated. Instead of using the geometry alias for the function that converts geometry to GeoJSON, it is using the function as as the alias! Thus, DataTables cannot find the data: "geometry" property in the data that's returned from the database.

This is the query Editor is trying:

SELECT wishlists_items.id as \"wishlists_items.id\", ST_AsGeoJSON(ST_Transform(ST_Centroid(wishlists_items.geom), 4326)) as \"ST_AsGeoJSON(ST_Transform(ST_Centroid(wishlists_items.geom), 4326))\" FROM wishlists_items ORDER BY wishlists_items.created_at desc LIMIT 10

I tried using an alias on a simpler function:

Field::inst( 'extract(year from wishlists_items.created_at) AS year' )
            ->set( false ),

And the problem in Editor's resulting SQL is still ignoring the year alias:

SELECT wishlists_items.id as \"wishlists_items.id\", extract(year from wishlists_items.created_at) as \"extract(year from wishlists_items.created_at)\" FROM wishlists_items ORDER BY wishlists_items.created_at desc LIMIT 10

I have found relevant code in the Query.php and Field.php files, and I tried tinkering with _dbField() and _buildField() functions, but I couldn't get the alias to be recognized when there's a function in the field name.

Is there a bug?

Executing IQueryable list server side with Entity Framework

$
0
0

This extension provides you to execute Datatable js request on Entity Framework IQueryable queries.
With "ToDataResult(request)" extension function, data can get with server side pagination very simply.

public JsonResult GetDataResult(DataRequest request)
    {
        DataResult result = context.People.ToDataResult(request);
        return Json(result);
    }

Install the package and use it;

$ Install-Package EFDatatable.Data -Version 1.1.0

If you have MVC project you can also use this helper

Viewing all 81907 articles
Browse latest View live