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

Column Render not rendering properly.

$
0
0

Hi All,

Request your help, when I manually execute the php program the output is as below(PHP Output), the "Output" column is an array , so in my ajax i have the below lines(AJAX Query), it is rendering the first array (0) properly , but the second array(1) the value is display as single line "FAILED FAILED FAILED" rather than multiple lines as

FAILED
FAILED
FAILED

PHP Output

    [0] => Array
        (
            [Server] => T1
            [Task] => T01
            [Output] => Array
                (
                    [0] => FAILED
                )

        )

    [1] => Array
        (
            [Server] => T2
            [Task] => T01
            [Output] => Array
                (
                    [0] => FAILED 
                    [1] => FAILED
                    [2] => FAILED
                )

        )

AJAX Query

            columns: [
                        { data: "Server" },
                        { data: "Task", className: "dt-body-left h8" },
                        { data: "Output",
                          render: function (data, type, row) {
                                           var odata = '';
                                           for (i=0; i<data.length; i++) {
                                                odata += '<p class="dt-body-left h8 text-danger" colspan="2">' + data[i] + '</p>'
                                           }
                                           return odata;
                                  }
                        }
            ]

How do I pass a parameter to a server script?

$
0
0

Pass the parameter from the JS script according to the documentation like this (https://editor.datatables.net/reference/option/ajax.data):

ajax:  {
        url: 'php/staff.php',
        data: {
            "user_id": 451
        }
    },

Sorry, but I didn't find how to accept it on the server. I do this:
$user_id = $_POST['user_id'];

DataTables swears, how is it correct?

Custom rendered data as stored functions

$
0
0

Hi,i have the same custom computed-rendered data fields in many different datatables and i want to save-store this rendered code as a function in myfunctions.js .

How can this be possible?How can i save this code in a function and how to call it inside data field so that i don't write the same code in many different locations?

I am confused about how to call the stored function in the "render" section of field.

eg. function (data, type, row) { ...} could be MyStoredFunction (data, type, row) {.... } ?

Does not longer work with postgrsql for dotnet core : Npgsql 3.x removed support for ...

$
0
0

I am using DataTable.net editor for dotnet core with postgrsql

Npgsql 3.x removed support for writing a parameter with an IEnumerable value, use .ToList()/.ToArray() instead

DataTable Edior issue with postgrsql

$
0
0

Hi
I postgrsql you got catalogs named like public and you can even create you own catalog in postgrsql
to navigate to a catalog in postgrsql u need to use . then table name or sp or function.
when i trying insert to a table name products in catalog pj i type pj.products i even try move the table to public and type public.products when it try doing a insert it will not report any problem or doing any modifcation or insert of data.

issue on map when try to get an array from datatable rows

$
0
0

hi
i have an issue when try to get all data-filter in column,
i wish return an array [0,1]

but i have an object

i use this code ( this is here Datables object)

  let t = this.rows().data().map(x => x[1]['@data-filter']).unique()
  console.log(t)
  t.forEach(x => {
      select.append('<option>'+x+'</option>');
   })

because it not return clean array, it have an issue in foreach

How to add second footer to print in Tfoot?

$
0
0

Guys, I can't print the second footer in <tfoot> tag?
How can I resolve this issue?

How to add a hyperlink to certain cells?

$
0
0

I would like to be able to add a hyperlink to certain cells, but only on some of my DataTables. I am using server side processing. I want to create a hyperlink to a form that I created that would allow for editing of some of the fields in the table row, then once editing is complete return them to the same table state that they left.

I'm able to create the column and make the data from the rest of the table move over to accommodate this, but I can't figure out how to fill the cell with a hyperlink.


Editor autocomplete return values

$
0
0

Good afternoon (o;

As my project already uses autocomplete from jqueryui I give it a go as well with the editor..
But I am stuck what to exactly return from the ajax call.

Got this framework I've found here:

            label: "Artikelnummer",
            name: "Artikelnummer",
            type : "autoComplete",
            minLength: 2,
            opts: {
            source: function (query, result) {
                        $.ajax( {
                            url: '/inc/get.products.php',
                            dataType: 'json',
                            success: function ( data ) {
                                result ( $.map( data,    function (item) {
                                    console.log(data.data);
                                    return {
                                        label: data.data.number, << no clue yet (o;
                                        value: data.data.number << no clue yet (o;
                                    };
                                }
                            )
                            )
                        }
                    });
            }
            }

The PHP code just returns an array with all products availabe, and the editor autocomplete should fill then two fields automatically when selected...

So my simple question..what exactly do I have to return in the ajax call to autocomplete so it displays the product list matching they typed input?

I'm not that JS guru (o;

thanks in advace
richard

add buttons to multiple tables

How to get the data of row?

$
0
0
  1. When we click new button it's appearing light box with all the columns. once enter the data when i click create i want to catch all the data with column names ( same thing i need for edit and delete also). I tried with submit it's not working out. Please provide me any examples so that it will helps me to move forward.
  2. After adding data to the datatable when i modify the data of particular column. i want to get the data with column name. as of now i can able to get only data not column name.
  3. Is there anyway i can create instead lightbox(to enter data) we can show editable mode inside datatable only.

Responsive layout for datatable in mobile

$
0
0

Hello,
I'm trying to adjust the responsive datatable but I can't do it.
I'd like to have every row in a different layout when I visit the page with a mobile. I'd like to have a layout like a "form layout" with the table headers on the left and the content of the row on the right, and the action buttons in the last line.
How could I do this?
thanks so much everyone

Datatable similar to .NET datagridview

$
0
0

Hi all,

Unusual question. I hope someone can assist.

I am trying to decide how best to use Datatables (the Editor specifically) with inline editing. In VB.NET I can create a datagridview. I can add, remove and update all within that datagridview. Then, when I want to send the data to SQL, I can do it in bulk (using bulkcopy) or iterating through the records to inject the data row by row,into a SQL table.
I want to do something similar with Datatables and/or the Editor.

What I want to do but don't know if it is possible:

1) Start with empty Editor
2) Using an "Add" button, add a blank row (or have the editor come up with a new row (row 1) with empty cells
3) Using inline editing, the user modifies all the columns they need
4) When the user types in any of the initial fields on row 1, a new second row, is created, empty and waiting on input
5) Repeat until all data is entered for 1, 2, 10 or 20 rows
6) Upload all data from table to SQL via AJAX (this is the only time AJAX is called/used)

Is this something that can be done with the Editor?

Kind Regards,
Jason

Different editor select list for each row of a datatable

$
0
0

Is it possible to list different items in a select list for a field in an editor window?
If I have a field called "Items", for the first row I only want to allow the user to select any one of "Item 1", "Item 2" or "Item 3".
For "Items" in the second row I only want the user to select from "Item 1" and "Item 2".
The third row would allow the user to select "Item 1", "Item 2", "Item 3" and "Item 4".

Table not displaying correct answer. What am I doing wrong?

$
0
0

The code for my table is here http://live.datatables.net/jofuhaca/13/edit It runs on my pc but not on the live link, not sure why.
What I am trying to do, is collect api data on a loop and look for a difference in the 'price' object.
The code all runs on my pc except it appears to be calculating and displaying one row out. Console.log shows..

i 0 maintst.js:45:16
L 0.00000249  M 0.00000249  D -0.00000249 maintst.js:46:16
i 1 maintst.js:45:16
L 0.00001957  M 0.00001957  D -0.00001708 maintst.js:46:16
i 2 maintst.js:45:16
L 0.00000062  M 0.00000062  D 0.00001895 maintst.js:46:16
i 3 maintst.js:45:16
L 0.00000584  M 0.00000584  D -0.00000522 maintst.js:46:16
i 4 maintst.js:45:16
L 0.00000001  M 0.00000001  D 0.00000583

i is the counter, L is the lastPrice value M is the current price and D is the difference. What I am after using the first line as an example is for D to equal zero, what is happening is .00000249 is being subtracted from L (or M) 0.00001957 on the next iteration, (i =1) to give -0.00001708 when that too should be zero. I cannot fathom why this is happening. As previously mentioned, I am very new to this so have probably missed something very fundamental.
Thank you for your help


How to disable a checkbox in Editor?

$
0
0

I've been trying to create a disabled checkbox in Editor but keep failing. I can always click inside the checkbox and change its value no matter which permutations of attributes and options I've tried. I've also modified one of your examples on http://live.datatables.net/rotivole/3/edit but get the same results. (I don't know if I broke anything by modifying that. Sorry, if I did.) I reduced the table to five people, added a 'Y' or a 'N' to the data and added my checkbox definition to Editor and DataTables but no matter what combination of attributes or options I tried, I could always click within the checkbox and change its value.

disabled:true
disabled:'true'
disabled:'disabled'
onclick:'return false';
etc...

$(document).ready(function() {
   
  //$.fn.dataTable.render.moment("M/D/YYYY");
  var editor = new $.fn.dataTable.Editor({
    table: "#example",
    fields: [
            {
                label: 'Name:',
                name: 'name'
            },
            {
                label: 'Position:',
                name: 'position'
            },
            {
                label: 'Office:',
                name: 'office'
            },
            {
                label: 'Age:',
                name: 'age',
              attr:{
                class:'aNumericField2',
                type:'number',
                maxlength:13,
                min:'0',
                max:'99999999',
                step:'0.01'
              }
            },
            {
                label: 'Start date:',
                name: 'start_date',
                type: 'datetime',
                format: 'YYYY/M/D'
            },
            {
                label: 'Salary:',
                name: 'salary'
            },
            {
              label: 'Alive',
              name: 'alive',
              type: 'checkbox',
              separator: '', 
              unselectedValue: 'N', 
              options: [{ label: '', value: 'Y' }],
              attr: {disabled:true}
            } 
    ]
  });

  $("#example").DataTable({
    dom: "Bfrtip",
    columns: [
            { data: 'name' },
            { data: 'position' },
            { data: 'office' },
            { data: 'age' },
            { data: 'start_date' },
            { data: 'salary' },
            { data: 'alive' }
    ],
    select: true,
    buttons: [
      { extend: "create", editor: editor },
      { extend: "edit", editor: editor },
      { extend: "remove", editor: editor }
    ]
  });
  
  $('#example').on('click', 'tbody tr td', function() {
    editor.inline(this);
  }); 

});

Odd behavior of numeric fields > 999

$
0
0

I found a weird issue when I'd click on a DataTables row to edit that row's data in Editor. If a numeric field had a value > 999, it would show in Editor as blanks. I traced it back to how I defined the numeric field. I wanted it to have 'type:number' as an attribute, so I first tried this:

{label: 'Pay Rate', name: 'Rate', id: 'Rate', type: 'text', attr:{class:'aNumericField2',type:'number',maxlength:13, min:'0', max:'99999999', step:'0.01'} }

That gives me the odd behavior as noted above. Changing the first instance of type from 'text' to 'number' results in a "SCRIPT5022: SCRIPT5022: Error adding field - unknown field type number." message so I was trying the 'type:number' as an attribute.

The only way I get the normal result of the Editor field displaying correctly was if I dropped the 'type:number' and its related attributes from the definition.

{label: 'Pay Rate', name: 'Rate', id: 'Rate', type: 'text', attr:{class:'aNumericField2',maxlength:13} }

Is there a way to define a numeric field other than as 'type:text'?

Hyperlink entire row or cell using data-href attribute

$
0
0

I saw the example in the documentation for using a column renderer to make the value in the column a hyperlink. However I wanted to make the entire row or cell a hyperlink, not just the text within it (and not using css display). I was curious how you would go about making a row or column a hyperlink using jquery delegated events and the data-href attribute. I got this working by simply referring to the actual table data with the following:

var rankTable = $('#myTable').DataTable();
$('#myTable').on('click', 'tbody tr', function() {
  window.location.href = `someurl/${table.row(this).data()[1]}`;
});

but i would like to know how to go about adding the data-href attribute to a td or tr if i wanted to be able to do something like the following:

<tr data-href='someurl/1234'>
  <td>Cell Data</td>
</tr>
$('#myTable').on('click', 'tbody tr', function() {
  window.location.href = $(this).data('href');
});

I swore I saw an example somewhere about adding attributes to rows or cells but can't seem to find it now.

Any Export Complete Event?

$
0
0

Hi, I have created a custom action under the buttons for exporting either CSV/Excel files. The export takes quite a bit of time so I have added a loading modal to notify the user - however, I am looking for a way to detect when the export is complete.

If there is some type of event that is fired so I can attach an event listener and have it close the modal once export has completed, that would be great! I have also (unsuccessfully) tried to implement some sort of callback function or promise, however it simply executes the code immediately every time and does not wait for the export to finish.

Working with Datatable and Blazor Server side

$
0
0

I love working with datatable but I can't use it with server side Blazor, is there anyone who has a really working example?
i followed a few posts here but i couldn't get it to work

Viewing all 81690 articles
Browse latest View live


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