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

FEATURE REQUEST: order option [index, 'asc'|'desc'] should allow any column selector, not just index

$
0
0

In particular, would like to see {string}:name selector allowed. Alternatively, allow 'order' option directly under the columns option, with 'asc', 'desc' as value (assume current index).

I've removed a hidden column from my home-grown underlying framework, and this has broken all of the datatable options which have order option based on index.


Checkbox Not Working

$
0
0

Hi,

There is no change in the database when I check the checkbox.

Controller: .Field(new Field("Offer"))


      {
                    label: "Offer",
                    name: "Offer",
                    type: "checkbox",
                     separator: "|",
                   options: [
                 { label: "", value: "1" }
                    ],
          },

   { 
                    data: "Offer",
                    className: 'text-left font-bold',
                    title: 'Offer',
                    render: function (data, type, row) {
             if ( type === 'display' ) {
                    return '<input type="checkbox" class="editor-offer">';
                }
                return data;

                    }

$('#' + tableId).on('change', 'input.editor-offer', function () {

    editor
        .edit($(this).closest('tr'), false)
        .set('Offer', $(this).prop('checked') ? 1 : 0)
        .submit();
} );

Why searchPanes button not work with searchPanes option???

Do CascadePanes work when searchPanes is initialized in button?

$
0
0

Hi, When i use dom: 'Pfrtip' Cascade and all configs work, when i use dom: 'Bfrtip', no configs apply.

How to handle event on clicking a link in td?

$
0
0

Hi,
I have a td as defined below.
<td class=" cell-td">
<a href="#"class="test"></a>
</td>
I need to perform some action on the click of link "a.test".
I tried doing:
$('#profile-table tbody').on('click', 'a.test', function (e) {
e.preventDefault();
console.log('test1');
});

It is not logging the value.
can u please help me in understanding the event handler for the links in td?

Datatable Editor DateFormat

$
0
0

Hi,

I get an error when I use the date format as follows.

Unable to cast value to be DateTime

     .Field(new Field("Vessels.ETA")
                       .Validator(Validation.DateFormat("Y-m-d"))
                       .GetFormatter(Format.DateSqlToFormat("Y-m-d"))
                       .SetFormatter(Format.DateFormatToSql("Y-m-d"))
                       )

My sql date format is like this.

2020-03-10 00:00:00.000

Thanks..

Apply validation to many fields

$
0
0

Hi, I am just wondering is it possible to apply multiple validations to multiple fields at a time? I am using editor with a large form (50 fields) and applying validations server side. I'm wanting to apply the same validation to many fields. I am trying this.

 ->on( 'preEdit', function ( $editor, $id, $values ) {

        if ( $values['importtest']['task_status'] > '3') {
 
            $editor
            ->field( 'importtest.FamilyName', 'importtest.FamilyNameAtBirth' )
            
             //not empty
              ->validator( Validate::notEmpty( ValidateOptions::inst()
                ->message( 'A Family name is required' )
               ) )
             //not more that 70 characters
            ->validator( function ( $val, $data, $field, $host ) {
               return strlen( $val ) > 70 ?
            'Family name length must be 70 characters or less' :
            true; 
             } )
            //no numbers, lowercase 
            ->validator( function ( $val, $data, $field, $host ) {
               return preg_match('/^(([A-Z\'][A-Z \' -]*[A-Z\'])|([A-Z\']+))$/', $val) < 1 ?
            'Family name must not contain numbers, must be in capital letters, and can only accept apostrophies, dashes, and spaces' :
            true; 
             } );
    }
 
})

this is causing error on update. It works fine if I remove 'importtest.FamilyNameAtBirth'.

Any help would be appreciated.

Editor: Editing a single row updates multiple rows on the server, reload multiple rows

$
0
0

Hi,
I need to know whether this is possible:

I have data in my Editor, and when a user updates a specific column (field), it causes updates to multiple rows and fields on the server. The server should then return an array of the new data for the rows that were updated.

However, at the moment, my understanding is that the Editor expects data for only 1 row back. So I have an issue, where it just replaces the 1 row that was initially updated with the first returned data object, even though an array is returned. Is it possible for the Editor to handle multiple rows returned after single row update and updating them locally based on their ID ? Or do I just have to reload the entire table after each edit ?

Hope that makes sense.


Integration between FixedColumns and a TreeTable plugin

$
0
0

Hi there,

I've an integration issue concerning the FixedColumns plugin. I'm trying to use it with this TreeTable plugin: ludo.cubicphuse.nl/jquery-treetable
Unfortunately, the two plugins are not working properly together, the fixed columns are not refreshed by a click in the arrow to expand/collapse the children rows. By the way, the arrow is also not changing his orientation when we click on it.

Is it possible for you to work on a solution for me? I tested some other TreeTables plugins but without success... :/ If you have any solution, it would be great!

My code sample is available here:live.datatables.net/jatusija/3/
Pay attention:
- in this live example, I don't know why, the TreeTable put the child line one line below the second, I don't understand why. I does not experiment this issue in localhost.
- there is also an issue with the icon, not shown. I suppose I didn't import everything needed :/

Once again, thanks a lot for your help.

Nicolas.

Editor DataTable Shows error in browser's console when I use input field type select2

$
0
0

I am using Editor Datatable,when I declare field of type select2 it shows error in console"Uncaught Error adding field - unknown field type select2", when I simply use type select dropdown works normally. Do I need to add specific select2.js file or does any select2 file comes with editor? Currently I am using https://cdn.jsdelivr.net/npm/select2@4.1.0-beta.1/dist/js/select2.min.js link.
I dont know where the issue is.

var editor;
$(document).ready(function () {
editor = new $.fn.dataTable.Editor({
"ajax": "/api/staff",
"table": "#example",
"fields": [{
"label": "PO No:",
"name": "PONo"
}, {
"label": "PO Line No:",
"name": "POLineNo",
"type": "select2",
"options":
[
{ label: "option1", value: "1" },
{ label: "option2", value: "2" },
{ label: "option3", value: "3" }
]
}]
});
});

how to use dependent set a value

$
0
0

editor1.dependent( 'option', function ( val )
{
if (val === 'value1' || val === 'value2')
{
return {show: ['field1', 'field2', 'field3']};
}
else
{
return {hide: ['field1', 'field2', 'field3']};
}
} );

in the code above I need to set a specific value to field1 how can I do?
Sam

What triggers the display of language strings?

$
0
0

I'm trying to figure out what causes the various language strings (emptyTable, zeroRecords, loadingRecords and processing) to display while using DataTables to display results from an AJAX call. I don't understand the difference between emptyTable and zeroRecords, nor when the loadingRecords and processing strings display.

My use case is that I make an AJAX call which might return anything from 0 to thousands of records. My expectation is that the processing string would be displayed before the AJAX call completes, then loadingRecords would show until all of the layout is complete, which would either show the rows or show the zeroRecords string. That obviously isn't correct. What I get is zeroRecords showing until the rows display if emptyTable is null, or emptyTable. Neither is correct - the table isn't empty nor are there 0 records. The records just haven't been displayed.

So, my question is, how do I show that the table is loading records after the AJAX call completes, and then show an appropriate message if there were, in fact, no records?

Thanks. Maybe this is simple, but I can't find anything in the docs that tells me what actually triggers the display of each of those state-dependent messages.

Display detailed info in modal without making ajax calls

$
0
0

Hi

I've been given a json datasource which I use with PHP to retrieve data to build my Datatable manually.
I mean, it is not serverside (yet). This json datasource has almost no parameters to query

Each record from json response has around 20 fields, but I only show in the table only 6, 7, the most important ones.
Each table's row has a small button with lupe icon in the last column

Is there a way to open a modal/lightbox and show all the other fields when clicking that button, without making ajax calls again? The json datasource has no param to query and give a specific record based on ID

Maybe there's some way to hide detailed info for each row and show all 20 fields in the modal when clicking each button

Thanks a lot for any tips/ideas you can give me

Is PDFMakes's vs_fonts.js file available via Datatables' CDN path-based call?

$
0
0

In the Download tool, PDFMake calls are now separate files, like this:

https://cdnjs.cloudflare.com/ajax/libs/pdfmake/0.1.36/pdfmake.min.js

However, PDFMake can still be downloaded via the combined, path-based call (along with other extensions/plugins) like this:

https://cdn.datatables.net/v/bs/pdfmake-0.1.36/datatables.min.js

My question is: Is there a parameter/path for PDFMake's vs_fonts.js file (e.g. https://cdnjs.cloudflare.com/ajax/libs/pdfmake/0.1.36/vfs_fonts.js) that I can add to the exiting call?

Something like this is what I was hoping for:

https://cdn.datatables.net/v/bs/pdfmake-0.1.36/pdfmake_vs_fonts-0.1.36/datatables.min.js

I would obviously have other frameworks in the call, too such as buttons, dt, etc.

If it's not available, could it be made available? it really helps to have the combined JS so there are fewer files to maintain.

Thanks in advance!

Matt

Default sort order when using DataTables?

$
0
0

How can I specify a default sort order of my recordset when using DataTables? Right now, the default sort order of the query is being ignored in my output.

Thank you.


How to add a class after row data has been changed

$
0
0

I am trying to add a CSS class to the changed table row once the data has been updated. I want to check to see if the "CheckedOK" column is checked. If it is, add a class. If it isn't, remove the class. Then deselect all the selected rows.
This is what I have:

editor.on('postSubmit', function (e, json, data, action) {
                if (action == 'edit') {
                    var dta = e.currentTarget.s.editData;
                    $.each(Object.keys(data.data), function (idx, value) {
                        if (dta['CheckedOK'][value] == true) {
                            $(data.data[value]).addClass('RowOK');
                        } else {
                            $(data.data[value]).removeClass('RowOK');
                        }
                    });
                }
                dtOrders.rows().deselect();
            });

I sure this isn't correct, but hopefully it is enough to get the idea across. I think when I check the value of CheckedOK I am actually checking the previous value. If so, what should it read to check the current value?

Editor Submit only runs once; need help figuring out why!

$
0
0
var ajaxEditor = new $.fn.dataTable.Editor(
    $.extend(true, {
        ajax: function(method, url, data, success, error) {
            if (data.action == 'edit') {
                data.data = JSON.stringify(data.data);
                $.post(app_settings.editor_ajax_link,
                    data,
                    function(data, textStatus, xhr) {
                        // code
                }).fail(function(jqXHR, textStatus, errorThrown) {
                    // code
                });
            }
        }
    }, editorOpts)
);    

// Here, changedRows are just a list of IDs prefixed with '#'
ajaxEditor
.edit(changedRows, false)
.submit();

My issue is that the ajaxEditor submits data to edit ONCE successfully, and then after that, it doesn't work.

keytable how to make a cell gain focus upon mouse click

$
0
0

I am using they keytable extention. Initialization and setting initial focus on a cell is working, and I can move focus about fine using the arrow keys. Clicking on a cell with the mouse does nothing - how do I enable mouse click to make a cell gain focus using keytable? It looks like it maybe should be automatic, but it is not working for me, so is there a way to enable that?

Control over Search/Filter HTML markup

$
0
0

Using Bootstrap...

Do we have control over the Search (Filter) input in the same way that we do Buttons?

That is, the ability to manipulate its HTML and inject it into another place on the page i.e.: table.buttons().container().appendTo($('.navbar'))?

Can I inject my own custom search bar into the first row, "f"? dom: "<'row'<'col-sm-12 col-md-6'l><'col-sm-12 col-md-6'f>>" +

DataTables finished loading

$
0
0

Hello,

How will I know if a datatable has started and ended loading?

Thanks,

tinac99

Viewing all 82208 articles
Browse latest View live


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