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

How do I use .search() to look for multiple values?

$
0
0

I have the following code. I would like to draw the table using data found in column 1 that contains both "Backlog" OR "Stretch". However, the | doesn't work. I've also tired ||. I've tried using an array but that didn't work either. If I search for just "Backlog" or just "Stretch" it works fine. I'd like it return the results when multiple values are found.

$(document).ready(function() {
    $('#example').DataTable().column(1).search("Backlog" | "Stretch").draw();

    } );

Is there also way to search for all values except one specific value (i.e. !Backlog )?


Storing Single Quotes Editor.

$
0
0

Is there a way to single quotes in the database. Below is the hack I came up with to hide the single quotes escape .

                    int locationNameFormPostion = 1;
                    string @locationName = request.Form[locationNameFormPostion].Replace("'", "`").ToUpper();
                    editor.Field(new Field("LocationName"));
                    editor.Field("LocationName").SetValue(@locationName);

How to edit Duplicate drop down values

What are peoples favorite/recommended RAILS backend gems/libraries for datatables?

$
0
0

Are there any ones that stand out over other ones? Do any support Editor? Are there any plans to release an 'official' rails backend library?

Allow id 0 in addition to dbValues

$
0
0

Hi,

In Editor, I have a simple join, showing a select dropdown field with some labels and storing its id number in db. The input is validated using ->validator('Validator::dbValues')

I would like to make this select field optional (not requred), so user should be able to select nothing (=placeholder). I can setup the placeholder options (incl. placeholderDisabled: false, placeholderValue: 0). But how can I allow the value 0 to be allowed for the validator in the PHP file?

Best regards,
marwi

Go to specific row id

$
0
0

Hello,
Is there a way to jump to specific TD id? I'm using pagination.

fixed column update- update footer values

$
0
0

thanks for datatable is awesome
i have a question, i have a table with a sum of columns values in the footer and fixed columns, so when the data changes the footer values should change but they don't. in the documentation of fixedColumns().update() state that we should update the new table which was created to deploy fixed column. example in the doc.

var table = $('#myTable').DataTable();

table.cell( 0, 0 ).data( 'New data' ).draw();
table.fixedColumns().update();

but i need to update the footer values of the new fixed table and the main table.
thanks in advanced

How can I create multiple rows based on other selected rowss?

$
0
0

Hello everyone!
I have a problem with DataTables Editor. I want to create multiple rows based on other selected rows!
Is it possible at all?
How can I duplicate multiple selected rows at the same time uses Editor?
please help me.


PHP Option on two tables

$
0
0

Hi,

Is it possible to join two tables in the PHP option class?

 Field::inst( 'users.site' )
        ->options( Options::inst()
            ->table( 'sites' )
            ->value( 'id' )
            ->label( 'name' )
        )

In the example table is "sites", but is it possible to connect it to another table, for example the table domains" and do a where domains.sites_id = sites.id?

Modify column data from bootstrap modal

$
0
0

Hi !

I have a datatable with an edit button placed in a row with a 'bt-modal' class.
When clicking it, it displays a bootstrap modal window.

I offer an update of the informations in the given TR in a bootstrap window (there's more informations to edit with complex validity controls). So far so good, this is server side, no problem for that.

Now, where I'm stucked, is when I try to update the informations of the row in the datatable after (or before, I can handle form control client-side) the modal is submitted.

In short (ok, I should maybe have started from here, sry) : How do I reference the datatable so that I can manipulate rows/cells data from my modal ?

Below my JS declarations/functions

$(document).ready( function() {
var forSearch = $('#Tmagasins').DataTable( {
        pageLength: 5,
        [other params like kanguage and so on]
}),
        // The modal call function
            $('.bt-modal').on( 'click', function () {
            tr = this.closest( "tr" );
            magid = forSearch.row(tr).id();
            trindex = forSearch.row(tr).index();
                         //this is just for testing and yes, it works
                                     /*trdata = forSearch.row(tr).data();
                         console.log(trdata);*/
                $('.modal-body').load('dsp_magasin.cfm?id='+magid+'&trindex='+trindex);
                    $('#modModal').modal({show:true});
        })
})

P.S : My HTML setup is pretty simple, as the datatable content is populated when page is loaded; let's pretend it's a basic/static HTML one.

Thanks + sorry for my weird English ... hope you'll get what I mean :)

Trying to Load JSON on DataTable

$
0
0

Hi!

I'm trying to use a JSON to load datatable rows, but the datatable always return me a error, that is: DataTables warning: table id=dt_basic - Requested unknown parameter 'id' for row 0, column 0. For more information about this error, please see http://datatables.net/tn/4

I get this JSON from the InitComplete function from another datatable e save the result on sessionStorage. Like this:

"initComplete": function (settings, json) {
sessionStorage.setItem('json', json);
}

The JSON returns me:

[{"id":"36566","nomeFantasia":"LOJAO DOS ALUMINIOS","titulo":"Ajuda para gerar e corrigir arquivo do Sped Fiscal","codigoPrograma":"9220","nome":"ALANO","status":"Aberto","dataAbertura":"11-12-2017 00:00","motivo":"Comercial"}]

my columns configuration is:

"aoColumns": [
{"data": "id"},
{"data": "nomeFantasia"},
{"data": "titulo"},
{"data": "codigoPrograma"},
{"data": "nome"},
{"data": "status"},
{"data": "dataAbertura"},
{"data": "motivo"},
{"data": function (data) {
if (data.status == 'Fechado') {
return '<a style="width: 100%" class="btn btn-primary btn-sm" title="Trâmite" id="editChamado" href="#ajax/chamados-edit.php?id=' + data.id + '&st=0"><i class="fa fa-edit"></i></a>'
} else {
return '<a style="width: 45%" class="btn btn-primary btn-xs" title="Trâmite" id="editChamado" href="#ajax/chamados-edit.php?id=' + data.id + '&st=1"><i class="fa fa-edit"></i></a><a style="margin-left: 5%; width: 45%;" title="Fechar" id="deleteChamado" href="#ajax/chamados-delete.php?id=' + data.id + '&acao=delete" class="btn btn-success btn-xs"><i class="fa fa-check"></i></a>';

                            }
                        }
                    }
                ]

my table:

Chamado Nome Fantasia Título Codigo Rotina Atendente Status Data Abertura Motivo Ação

Please, anyone send me a ligth!
Thank you!

Warning (tech-note 4) fired for empty cells (not null nor undefined, simply = '')

$
0
0

I'm using DataTables-1.10.16.

All works fine with Firefox and Chrome.

But with IE11 I get the DataTables warning: table id={id} - Requested unknown parameter '{parameter}' for row {row-index}, column{column-index}.
It clearly appears for each cell having content = ''.
The warning fires not only when initially displaying the table content, but also each time a cell content is changed to ''.

Since it happens with IE11 only, my first guess was about a comma after the last member of an object or array. But:
* IE uses to fire a console alert when it happens, and it's not the case here
* nevertheless I carefully checked for that and didn't found anything
* and actually, regarding the tech-note suggestion about if using dt-init columns, my dt-init is dynamically populated by push() so no additional comma can appear

Then I examined the very content of the involved cells. But:
* their content comes from a source that I can console.log() and they well appear as a simple empty strings, not undefined nor null.
* anyway, in case there is some unidentified bug in my code when the data is processed between source and DataTable.row.add(), I just tried to add defaultContent: '' to each of the dt-init.columns members, and it keeps firing the warning.

So now I feel totally stuck: what else should I examine to explain what is happening?
TIA.

PDF export button spinner not stopping?

$
0
0

Was using the standard HTML5 export extension and noticed my PDF button didn't stop spinning after completion. Tried the online example https://editor.datatables.net/examples/extensions/exportButtons.html and noticed the same behavior. Tried with Firefox v57, Chrome v63 and Edge v25 with same results in all. Everything functions exactly as it should and produces the correct result, spinner just never stops?

Row grouping show all result in a group

$
0
0

Hi community,

I am having a challenge in row grouping. Would you help solve this? Here's my scenario.

I make the row grouping work. with pagination. It's good, it's working fine. But what's happening is for example,

I have 100 apples.

So in first the first page, I can show, only 10 apples. So the group will show apples(10). In the next page it will also show the same.

Here's what I want to achieve. Can I show all apple at once? So the group will show apple(100). It's like the page will adjust. If I have 100 apples and 30 oranges, the first page will show 100 apples and the second page will show 30 oranges. Is this doable?

Thank you so much. I appreciate it.

Get Row Data and Pass to my JavaScript Function

$
0
0

I am adding a view/Edit Button to each row of my table , On click i have to get the data and pass it to my javascript function , but unable to do so ,

Adding the button/links like this

 "columnDefs": [ {
        "targets": -1,
        "data": null,
        "defaultContent":
             '<a id="btn-view">View-</a>'
          +  '<a class="btn-edit">Edit</a>'
        } ]

   $('#allMemberTable tbody').on('click', '.btn-edit', function (e) {

      var data = table.row( $(this).parents('tr') ).data();
       console.log("data ="+data[0]);

       // Getting Row data scuccessfully
      test(data) ;   // This is not getting called ,   it is not recognizing this metod , giving error , test is not a function , i tried with this.test() , but same

   });

 // Getting Row data scuccessfully
      test(data) ;   // This is not getting called ,   it is not recognizing this metod , giving error , test is not a function , i tried with this.test() , but same

please correct me or give any other way around ( sorry for this basic question)

EDIT: Reformatted post using Markdown


Duplicate button for multiple selected rows is only updating rows

$
0
0

https://editor.datatables.net/examples/api/duplicateButton.html

using the example, I added the button to duplicate selected rows.

action: function(event, datatable, node, config) {
    editor.edit(
        datatable.rows({selected: true}).indexes(),
        {
            title: 'Copy record',
            buttons: 'Create from existing'
        }
    ).mode('create');
},

ajax options for editor:

edit: {
    type: 'PUT',
    url: '/api/hifCableRequestRow',
    data: function (data) {
        return JSON.stringify(data.data);
    },
    "contentType": "application/json"
},
remove: {
    type: 'DELETE',
    url: '/api/hifCableRequestRow',
    data: function (data) {
        var crfkeys = [];
        for (var crf in data.data) {
            crfkeys.push(crf);
        }
        return {'crfkeys': crfkeys};
    }
},
create: {
    type: 'POST',
    url: '/api/hifCableRequestRow',
    data: function (data) {
        return JSON.stringify(data.data);
    },
    "contentType": "application/json"
}

request

{123123: {...}, 123124: {...}, ...}

If I select multiple rows, and click the new copy button, it sends a PUT request instead of a POST request. Any thoughts on what I might be doing wrong? Perhaps this is intended and I just need to make my server handle that payload as a create? How can I distinguish the requests?

Row Subgrouping

$
0
0

Hello Community,

I am making a reports table. Would you help me with this challenge I am facing now?

I attached a picture showing my current table.

What I want to do is to have a subgroup in my table. I already have a grouping per area.

Now withing that area, I also want to add a grouping total per product. Please see attached photo.

Hope you can help me with this. I appreciate it. Thanks! :)

Adding a total in the footer.

$
0
0

Hello Forums,

I am using DataTables for the first time. I came to this problem where I need the sum of rows in the footer.

I have tried the footer callback, but I can't make it work. Would you help achieve this? Please guide where I might be wrong.

Here is my code.

/* Data tables*/
$('#table-summary-per-customer').DataTable({
"footerCallback": function ( row, data, start, end, display ) {
var api = this.api(), data;
// Remove the formatting to get integer data for summation
var intVal = function ( i ) {
return typeof i === 'string' ?
i.replace(/[\$,]/g, '')*1 :
typeof i === 'number' ?
i : 0;
};
// Total over all pages
total = api
.column( 4 )
.data()
.reduce( function (a, b) {
return intVal(a) + intVal(b);
}, 0 );
// Total over this page
pageTotal = api
.column( 4, { page: 'current'} )
.data()
.reduce( function (a, b) {
return intVal(a) + intVal(b);
}, 0 );
// Update footer
$( api.column( 4 ).footer() ).html(
'$'+pageTotal +' ( $'+ total +' total)'
);
}
});

And my HTML

<table id="table-summary-per-customer">
<thead>
<th>Customer</th>
<th>Month</th>
<th>Year</th>
<th>Net Sales</th>
</thead>
<tfoot>
<tr>
<td></td>
<td></td>
<td></td>
<td></td>
</tr>
</tfoot>
<tbody>
<?php foreach ($test as $result): ?>
<tr>
<td><?php echo $result['Customer']; ?></td>
<td><?php echo $result['Month']; ?></td>
<td><?php echo $result['Year']; ?></td>
<td><?php echo $result['NetSales']; ?></td>
</tr>
<?php endforeach ?>
</tbody>
</tfoot>
</table>

Thanks a lot. I appreciate it . :)

preGet not working

$
0
0

I want to change the field value of pregroupdata.status before datatable read from database. I use preGet event to implement. But it is not work.

There is my code.

<?php
header("Conten-Type:text/html;charset=utf-8");
/*
 * Example PHP implementation used for the index.html example
 */

// DataTables PHP library
include( "../../php/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;

// Build our Editor instance and process the data coming from _POST
Editor::inst( $db, 'pregroupdata' )
    ->fields(
        Field::inst( 'pregroupdata.appdate' ),
        Field::inst( 'pregroupdata.status' )->set(Field::SET_BOTH),
        Field::inst( 'pregroupdata.setupdate' ),
        Field::inst( 'pregroupdata.pastoralid' )->validator ( 'Validate::notEmpty' )
                                   ->options ( Options::inst()
                                                ->table( 'pastoral' )
                                                ->value( 'id' )
                                                ->label( 'name' )
                                             ),
        Field::inst( 'pname.name' ),
        Field::inst( 'pregroupdata.zoneid' )->validator ( 'Validate::notEmpty' )
                               ->options ( Options::inst()
                                                ->table( 'zonedata' )
                                                ->value( 'id' )
                                                ->label( 'name' )
                                             ),
        Field::inst( 'zname.name' ),
        Field::inst( 'pregroupdata.leaderid' )->validator ( 'Validate::notEmpty' )
                                 ->options ( Options::inst()
                                                ->table( 'leader' )
                                                ->value( 'id' )
                                                ->label( 'name' )
                                             ),
        Field::inst( 'lname.name' ),
        Field::inst( 'lname.phone' ),
        Field::inst( 'lname.cellphone' ),
        Field::inst( 'lname.identity' ),
        Field::inst( 'pregroupdata.groupname' ),
        Field::inst( 'pregroupdata.gdate' ),
        Field::inst( 'pregroupdata.gtime' ),
        Field::inst( 'pregroupdata.gplace' ),
        Field::inst( 'pregroupdata.property' ),
        Field::inst( 'zlname.name'),
        Field::inst( 'zlname.phone'),
        Field::inst( 'zlname.cellphone'),
        Field::inst( 'zlname.identity' )
    )
    ->leftJoin('leader as lname', 'pregroupdata.leaderid','=','lname.id')
    ->leftJoin('zonedata as zname', 'pregroupdata.zoneid','=','zname.id')
    ->leftJoin('pastoral as pname', 'pregroupdata.pastoralid','=','pname.id')
    ->leftJoin('leader as zlname', 'zlname.id','=','zname.leaderid')
    ->on('preGet', function($editor, $id){
        $editor
            ->field('pregroupdata.status')
            ->setValue('test');
    })
    ->process( $_POST )
    ->json();

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

select extension apply only selected columns??

$
0
0

select extension apply only selected columns??.

is it possible.?

Viewing all 81802 articles
Browse latest View live


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