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

Parent / child editing with Editor doesn't store parent id

$
0
0

Hello,

I used this example https://datatables.net/blog/2016-03-25 and when I create a new child entry the new chield entry doesn' store the parent id. This makes the link between parent and child entry impossible.

Is it a common bug or did I something wrong? Should I post my complete source code?

Kind regards

Patrick


Date range in searchCols

$
0
0

Hi,

I'm a relative newbie to both development and DataTables, but not shy of diving in at the deep end. Unfortunately I've lost about 3 hours of my day trying to solve this (what I hope is a) simple issue...

Can anybody please tell me how I filter on a date range using searchCols, please?

$('#example').dataTable( {
  "searchCols": [
    null,
    { "search": "2016-06-01~2017-02-01" },  // this is the range filter I want to use
    null,
    null
  ]
} );

Cheers

Andy

How to open a form on the web page without pop-up window?

$
0
0

How to open a form on the web page?
Without pop-up window.

Using Buttons plug-in to export table with dynamically added data?

$
0
0

Ahoy! I'm using DataTables with the Buttons extension with the hope of being able to easily copy-to-spreadsheet the contents of my table. However, it's a table that the user modifies on the fly, with contenteditable cells.
Is it possible for exportData() to get the most recent data? (I saw an old post that seemed to say no, but I want to double check, since it seems like an oft-desired use case).

Thank you!

uncaught exception: FixedColumns already initialised on this table

$
0
0

Hi,

I am currently programming an ajax-based website, which loads ALL its content always via ajax. There are a lot of datatables initialised when surfing through the site, but only one specific table has the fixedColumns option to true.

When I load this table, then load some other stuff into the website (the datatable disappears) and load the pagecontent with this table again, I get this error in my console:

uncaught exception: FixedColumns already initialised on this table

Thing is: all datatables get created through the same js function I wrote, and there the option destroy is set to true. This should prevent the "already initialised" error from popping up, as - if I understand the destroy option correctly - whenever a datatable is already initialised, it will get destroyed and then initialised again, automatically...?

Furthermore, all the tables get saved in an array while created -->

datatables[tid]=$("#"+tid).DataTable( { destroy: true, .......

I already tried just manually destroying ALL available tables:

var _tmp=Object.keys(datatables);
$.each(_tmp, function( index,value ) {
    if ($("#"+value).length==1)
        datatables[value].destroy();
});

But still the error pops up. How is that even possible??

If there is no easy answer without reviewing all of my code (there is a lot), is there at least a way catch this error and "UNinitialise" the table on-the-fly?

Thank you for your suggestions!
Marcus

Upload image file name - incorrect

$
0
0

I need some help. I have been successful in uploading images and they are being stored on to my server. But the trouble is when I look in my database the file name is incorrect. Not sure why that it is.

According to my database the incorrect file name is "editor-fileName". But according to my saving feature of this line of code...

->upload( Upload::inst( $_SERVER['DOCUMENT_ROOT'] . '/images/.../profile__ID__.__EXTN__' )

This gives the correct file name on my server. But storing it into the database with this line of code is incorrect...

->upload( Upload::inst( $_SERVER['DOCUMENT_ROOT'] . '/images/.../profile__ID__.__EXTN__' )
                                ->db( 'Table', 'ID', array(
                                    'Field' => $pathToImg . Upload::DB_FILE_NAME
                                ) )

But according to the documentation: https://editor.datatables.net/manual/php/upload#Database-information

It says that "Upload::DB_FILE_NAME File name (with extension)"

But it's not doing what I want it to. How do I tell it the File Name is what I saved it to? How do I do that?

How to add row to DataTable from Json object in ajax success response

$
0
0

Hi,

I have a HTML table in one of the VIEW with 7 data columns and last column have buttons(Actions). Initially it loads and displays data from model collection and I am converting it to Jquery DataTable in $(document).ready() function. So the datatable gets converted and displayed successfully when view is rendered.
Further I have a Add New Record form section below this table and I want to add multiple rows to the datatable through this section. While adding new records on 'onclick' of a Save button I am making ajax call to controller and returning newly added records collection in Json format (return Json(new { Status = "Success", Data = Tasks }, JsonRequestBehavior.AllowGet);
But I am facing issue while adding this object to datatable. Below is my code in $.ajax({... success: section

        if (response.Data != null) {
                    var taskData = response.Data;
                    var taskTable =  $('#tasksTable').DataTable();
                    taskTable.row.add([
                                taskData.Col1,
                                taskData.Col2,
                                taskData.Col3,
                                taskData.Col4,
                                taskData.Col5,
                                taskData.Col6,
                                taskData.Col7,
                                "Actions" : "FIXME"     //added this line by refering to one of the solution on google. no idea how to add
                                                                    buttons in column dynamically
                     ] ).draw();
                }
  1. What is the exact syntax of adding rows to datatable through javascript. Saw many different ways of doing it on google and none is working for me. sometimes it say add method is undefined. sometimes it say 'datatables warning table id example requested unknown parameter '0' for row 4, column 0.' i am getting this error with above syntax. sometimes it was adding multiple rows with all null columns at the top of the table.
  2. How can we add action buttons to datatable dynamically?
  3. What should I use .dataTable() or .DataTable()?

Please suggest a correct solution as I have already spent lot of time on this and got no success.

Thanks.

Editor Custom Form

$
0
0

Hi,
I am using the editor with a custom form and it works great. The custom form is generated through the use of a Jade like template compiler (vibe.d -- diet templates). This allows me to embed 'D' code in the template so at load time I can alter the output HTML.
The following is the definition in the template language.

    div#customForm
      fieldset.name
        legend Path To Device
        editor-field(name='depotName')
        editor-field(name='clientName')
        editor-field(name='rtuName')
      fieldset.name
        legend device
        editor-field(name='deviceName')
        editor-field(name='serialNumber')
        editor-field(name='assetNumber')
        editor-field(name='location')
        editor-field(name='ipAddress')
        editor-field(name='deviceType')
        editor-field(name='deviceStatusMessage')
        - if (!anySet(perms[Permissions.printerQuiesce..Permissions.printerQuiesce+1]))
          editor-field(name='quiesce')
        - if (!anySet(perms[Permissions.printerManualDataUpdate..Permissions.printerManualDataUpdate+1]))
          editor-field(name='serviceTag')
          editor-field(name='eventId')
      fieldset.editable
        legend User Configurable Fields
        - if (anySet(perms[Permissions.printerQuiesce..Permissions.printerQuiesce+1]))
          editor-field(name='quiesce')
        - if (anySet(perms[Permissions.printerManualDataUpdate..Permissions.printerManualDataUpdate+1]))
          editor-field(name='serviceTag')
          editor-field(name='eventId')

The '- if' statements are executed at load time and basically they are checking a bit map of user permissions for the current session user and will cause the appropriate HTML to be generated. Based on the user permissions I alter the location of the fields on the form.
What I would also like to do is not allow input for the quiesce, serviceTag, and eventFilter fields unless they are generated under the User Configurable Fields section of the form. Can I add some tag to the editor-field (like readonly) to achieve this without resorting to javascript after the load. I would rather not have anything to do with the permissioning show up in the loaded page.

I appreciate any assistance you may be able to provide.


PreEdit or PostEdit not working to setValue

$
0
0

PreCreate is working !

->on('preCreate', function($editor, $values) {
            if (($values['field1'] + $values['field2'] + $values['field3'] + $values['field4']) > 29) {
                $_SESSION['user_who']['sumarization'] = "yes";
            } else $_SESSION['user_who']['sumarization'] = "no";

            $editor
                ->field('question')
                ->setValue($_SESSION['user_who']['sumarization']);
        })

PreEdit is not working :(

->on('preEdit', function($editor, $values) {
            if (($values['field1'] + $values['field2'] + $values['field3'] + $values['field4']) > 29) {
                $_SESSION['user_who']['sumarization'] = "yes";
            } else $_SESSION['user_who']['sumarization'] = "no";

            $editor
                ->field('question')
                ->setValue($_SESSION['user_who']['sumarization']);
        })

PostEdit is not working :(

->on('postEdit', function($editor, $values) {
            if (($values['field1'] + $values['field2'] + $values['field3'] + $values['field4']) > 29) {
                $_SESSION['user_who']['sumarization'] = "yes";
            } else $_SESSION['user_who']['sumarization'] = "no";

            $editor
                ->field('question')
                ->setValue($_SESSION['user_who']['sumarization']);
        })

Please you help and thank you very much :-)

Duplicate click without must to selected

$
0
0

If it can be done as follows:

               $('a.editor_create').on('click', function (e) {
                    e.preventDefault();
                    editor.create({
                        title: 'CREATE NEW ROW',
                        buttons: 'CREATE',
                        onEsc: 'blur'
                    });
                });

                $('#example').on('click', 'a.editor_duplicate', function (e) {
                    e.preventDefault();
                    var values = editor.edit(table.row({
                        selected: true}).index(), false).val();
                    editor.create({
                        title: 'DUPLICATE THIS ROW',
                        buttons: 'DUPLICATE',}).set(values);
                });

                $('#example').on('click', 'a.editor_edit', function (e) {
                    e.preventDefault();
                    editor.edit(
                        $(this).closest('tr'),{
                            title: 'EDIT THIS ROW',
                            buttons: 'UPDATE',
                            onEsc: 'blur'
                        });
                });

                $('#example').on('click', 'a.editor_remove', function (e) {
                    e.preventDefault();
                    editor.remove(
                        $(this).closest('tr'),{
                            title: 'DELETE THIS ROW',
                            message: 'Want to delete?',
                            buttons: 'DELETE'
                        });
                });

when I click on the create, update, delete, duplicate.

Click the row without the required selection (selected) - click creation without necessarily choosing works without a problem, then work to update and removal.

The problem is that without duplicating the selection does not work.

I want so I clicked without necessarily duplicating row selection, is it possible?

Button click to change value

$
0
0

I ask you and please you for help me for small source code for - button click to change value:

  1. example - this is working
$('a.editor_create').on('click', function (e) {
                    e.preventDefault();
                    editor.create({
                        title: 'NEW ROW',
                        buttons: 'CREATE',
                        onEsc: 'blur'
                    });
                });
  1. example:

https://editor.datatables.net/examples/api/triggerButton.html - for add cost price.

I want to source code for I click to CHANGE, then field will changed to value in string - 'YES'.

Thank you.

Problem Child row does not show in automatic to display

Support for parent-child-grandchild tables

$
0
0

I have an application requirement to display three-levels of hierarchy. The examples show only parent-child.

This question was asked and answered No back in July 2015 (https://datatables.net/forums/discussion/28700). I could not find mention of this feature in the release notes since. Does anyone know if support has been added? Has anyone found a solution or work-around?

Thanks,
John

Scroller causes fixed width

$
0
0

When I use Scroller the width is set to 980px and creates a lateral scrollbar.

Is there a way to adjust the width whilst using Scroller?

preInsert like preEdit

$
0
0

Hi,

I have few columns those not part of form and not part of table but must be updated while save data into database table.

for example , last_updateby column is in database Table which has to be updated at the time of New record insertion/ or Edit with login session account id.

how to do this.

Regards.
Sunil


Do something beside load table

$
0
0

Hi Everybody,
i have a datatable which i'm loading via Ajax.
in the server side i'm prepering the data for the table and prepare another data for another thing
i want, beside the table loading, to do another thing with the other data i've prepared
so i added to my ajax code a success event, but it replace the table loading and i only can do the other thing
i can't separate between the table loading and the other thing because they are connected, meanning the other thing is influenced by the table loading(changes)

i tried also fnDrawCallback but i don't know how to pass the data of the other thing
Here's the Ajax code with success event:
"ajax": {
"url": "/Entreaties/GetEntreaties",
"data": function (d) {
d.status = 0;
d.firstLoad = firstLoad;
d.jAdvanceSearch = JSON.stringify(new AdvanceSearch());
d.freeText = $("#table_filter input").val();
},
"type": "POST",
"dataType": "json",
success: function (data) {
$.each(data.contactWaySum, function (key, value) {
alert(key + ": " + value.ContactWay);
});
},
error: function (xhr, textStatus, errorThrown) {
console.log(xhr.responseText);
}
},

Thank you all for your help

Does the DataTable run any process when search filter is active?

$
0
0

First of all, DataTable is awesome!!!

I set a table to organize the inventory of the company I work for, and we have a cell (td.editable) to handle the quantity of some product. Then when $(document).ready() I bind a ".on('dblclick',function(){})" to create an input on-the-fly in the style of the phpMyAdmin. Then bind a .on('keydown') to capture ENTER key press and a ".on('blur')" to capture the input lost focus event, then save the changes or cancel on ESC key.

Everything works fine if the search is null, but if we search for something and dblclick the td.editable, the input is blurred a few moments after it's created.

What could be happens and how can I fix this?

editor fields: how to add "select2" to a field if another field value has a certain value?

$
0
0

Is it possible to conditionally change the input form type in editor?
I have a table with a list of transports associated to an order. Loading and unloading destination can be any string but if the transport type is a ship then only pre-loaded list of ports should me allowed.
That is required for statistics purpose where a misspelling of the port name can ruin the results.

Code is like bellow:

$(document).ready(function() {
    var editor = new $.fn.dataTable.Editor( {
        ajax: 'php/pageOrderTabTransport.php?id_order=' + id_order ,
        table: '#tabel_transport',
        fields: [
            {
                label: "Type:",
                name: "otc_transport.id_tip",
                type: "radio",
                ipOpts: [
                    {label: '<i class="fa fa-ship fa-2x color-1 space-bottom-1"></i> Ship', value: '1'},
                    {label: '<i class="fa fa-plane fa-2x color-2 space-bottom-1"></i> Plane', value: '2'},
                    {label: '<i class="fa fa-truck fa-2x color-3 space-bottom-1"></i> Truck', value: '3'},
                    {label: '<i class="fa fa-train fa-2x space-bottom-1"></i> Train', value: '4'},
                    {label: '<i class="fa fa-cogs fa-2x color-4 space-bottom-1 "></i> Custom', value: '5'}
                ],
                default: "1"
            },
       {
        label: "Loading from:",
        name: "otc_transport.loading_city"

/////   if Type is 1 (ship) then instead of regular string to be entered, user must select2 from a list of enlisted ports.
////    so I need to add something like:
                type: "select2",
                options: ListOfPortsLoad()

            },
// more code...

Maximum multi row edit?

$
0
0

If I select any number of rows and multi edit a column
only the first 12 rows actually get updated with the edit.

Is there a hard coded limit or am I doing something wrong?

Thanks

How to hide a coloum from dataTable

$
0
0

I'm using serverside processing . there some pages does have data with usergroups and some don't. when sending data im passing a parameter call "groupEnable" with value of true or false.
How can I check this in js and show coloumns with data only have groupEnable == true.

js

"columns": [
{"data": "groupname"},

data

        $response = array(
            "draw" => intval($draw),
            "recordsTotal" => $total,
            "recordsFiltered" => $total,
            "groupEnable" => $groupEnable,
Viewing all 81387 articles
Browse latest View live


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