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

if inside column definition?

$
0
0

Hi!
I would like to add a dynamic column to my table based on a variable that has different values.

I am using:

var sroles = ... different int value ... ; 

  // On page load: datatable
  var table_cards = $('#table_cards').DataTable({
    "ajax": "data-search.php,
    "columns": [
      { "data": "data1" }, 
      { "data": "data2" },
      { "data": "data3" },
      { "data": "data4",   "sClass": "cardname" },
      { "data": "data5" },
      { "data": "data6"},
      { "data": "data7", "sClass": "integer2"},
      { "data": "data8", "sClass": "integer"},
      { "data": "data9", "sClass": "integer"},
      { "data": "data10"},
      { "data": "data11"},
    if(sroles == 1) { THAN ADD  { "data": "data12" } }

    ],

is that possible? thank you in advance!


editor field className

$
0
0

I am trying to add a class to the select element when inline editing. The class gets added at the wrong level, it isn't on the select, but on the top level so the dropdown is showing up with the wrong style. Any ideas on how to get that to add tot he <select> element?

I have tried adding it to the keys in the datatable and the fields definition in the editor options. The class gets added, always in the wrong place, the class needs added to the select element and for some reason it is rendering with "form-control" instead.

this adds the class to the element;

<div class="DTE_Field DTE_Field_Type_select DTE_Field_Name_code form-control-sm">   
    <div data-dte-e="input" class="col-lg-8 controls">
        <div data-dte-e="input-control" class="DTE_Field_InputControl" style="display: block;">
               <select id="DTE_Field_cropCode" class="form-control">
fields: [                        
                        {
                            name: "code",
                            type: "select",
                            className:"form-control-sm"
                        }

this add the class to the td element

keys: {
                        editor: editor,
                        editOnFocus: true,
                        columns:[1,2,3,4,6,7,8],
                        className:"form-control-sm"
                    },

How can I remove options that aren't applicable to current filter?

$
0
0

So I'm using the following example
https://datatables.net/examples/api/multi_filter_select.html

As you can see in the example, if I select a name to filter by, and then if I attempt filter again by position, it displays all positions rather than just the position for that name.

Is there I way that could implement this feature so that it automatically filters any selections that aren't applicable to the current selected option?

Thanks

Duplication of datatable search and paging with the saved page of my website

$
0
0

I need to use saved pages of website for future reference but my saved page has duplicate search,paging how can I avoid getting like that please help me with this

Is their a resolution to the Editor Entry Edit error after submitting

$
0
0

Editor 1.9.2

The error:

dataTables.editor.min.js:96 Uncaught TypeError: Cannot read property 'action' of null
at dataTables.editor.min.js:96
at Object.e.complete (dataTables.editor.min.js:77)
at c (jquery-3.4.1.min.js:2)
at Object.fireWith (jquery-3.4.1.min.js:2)
at l (jquery-3.4.1.min.js:2)
at XMLHttpRequest.<anonymous> (jquery-3.4.1.min.js:2)

My success function on Editor ajax post:

            success: function (d) {
                editor.destroy();
                $b('#requests').DataTable().ajax.reload(null, false);
            }

The table is updated properly, but the above error occurs and prevents any other edits.

Is generator not working as intended?

$
0
0

I just tried using the DataTables Editor generator, however it appears that almost none of the "customization" settings for extensions are working. Is anybody else experiencing this issue?

select-info element above & below

$
0
0

I have a table with row selection enabled. I would like to see "n rows selected" displayed both above and below the table, especially if my table has many rows. I specify:

'dom': 'piBlrtpi',

The "select-info" span element, however, shows only for the last "i" in the 'dom' option. And so I get "n rows displayed" only on the bottom of my table.

What am I missing?
Thanks!
Anna

Showing displayed url links from JSON file clickable to download a file

$
0
0

Hi There,

I've had a look at this and don't get it. https://datatables.net/reference/option/columns.render

I need to show column 3 display data (url's) as clickable.

$(document).ready(function() {
$('#example').DataTable( {
    "columnDefs": [ {
    "targets": 3,
    "data": "download_link",
    "render": function ( data, type, row, meta ) {
      return '<a href="'+data+'">Download</a>';
    }
  } ]
    <!--"serverSide": true,-->
    <!--"processing": true,-->
    "ajax":{
        "url":"https://opendata.arcgis.com/datasets/TheFile.geojson",
        "dataSrc": "features"
        <!--"dataSrc": "tableData"-->
    },
    "columns": [
      { "data": "properties.BoreholeId"},
      { "data": "properties.ArchiveId" },
      { "data": "properties.Description" },
      { "data": "properties.UNCPath" },
    ],
    dom: 'lfrtBip',
        buttons: [
            'copy', 'csv'
        ]
  });

Is this possible with the column render api?

Cheers

RockE


Datatables Working on Local Host but when published to Web app get error 404

$
0
0

Hi,
I have an issue when using aspnet.core 2.1, I have datatables controller for my database which connects to the azure hosted sql server database.
This works fine when using IIS Express Localhost however when I publish the project to a web application I get an the following error,
DataTables warning: table id=example - Ajax error. For more information about this error, please see http://datatables.net/tn/7.
The connection string I am trying to use has windows login and I believe this error may be due to the api request (http post and get) as it says the api url cannot be found error 404 or possibly due to the antiforgery token in the ajax request?

Multiple click events in when editing datatables inline

$
0
0

I know it's been asked before but I can't see to get my datatable click events to work correctly. I have tried to remove the event and rebind it every click however I am still getting events = X times the number of clicks

Thanks in advance for your help

$('#jsTable')
                .off('click.rowClick')
                .on('click.rowClick', 'tbody td.editable', function (e) {
                var rdata = spooltable.row(this).data();
                var cellData = spooltable.cell(this).data();
                var colindex = spooltable.cell(this).index();
                console.log('Hi Fred'); 

Create with some defaults

$
0
0

I am trying to do a create with some editing of the field from the same editor that gets used for a Edit. Should this be possible? Pressing my button results in nothing happening.

buttons: [
{
extend: "create",
text: 'New Entry',
action: function ( e, dt, node, config ) {
editor.field( 'field_one' ).hide();
var randomstring = "abc";
editor.field( 'field_one' ).val(randomstring);
editor.field( 'status' ).val('New');
}
},

Also, is it just me or does code formatting not work sometimes and the code button sometimes trim CR.

How do I prevent form error messages from causing editor buttons from being moved below the form?

$
0
0

In addition to field level errors displaying below each field in the default editor template I also display a form level error message which displays by default at the bottom of the editor form. The issue I am having is when the message exceeds a certain length it is causing the form buttons to be shifted below the bottom of the editor.

if the message is short the form looks like as expected:

If the message is longer the form buttons are pushed down below the bottom of the form like this:

The code I am using in the controller that returns the error message is below where I set the value of Error with whatever error I want to display.

    response = new DataResponse<TModel>
    {
        Data = rowData,
        Error = errs.Any() ? "Item cannot be saved. See errors above" : "",
        FieldErrors = errs
    };

    ...

    return Json(response);

Where DataResponse and IDataResponse) code is:

    public class DataResponse<T> : IDataResponse<T>
        where T : BaseModel, new()
    {
        public DataResponse()
        {
            FieldErrors = new List<FieldError>();
        }

        public List<T> Data { get; set; }
        public string Error { get; set; }
        public List<FieldError> FieldErrors { get; set; }
    }

    interface IDataResponse<T>
        where T : BaseModel, new()
    {
        List<T> Data { get; set; }
        string Error { get; set; }
        List<FieldError> FieldErrors { get; set; }
    }

How do I prevent longer form level error message from causing the form buttons from being pushed off the bottom of the form? I would make a custom template but there is not documentation on how to configure the are where buttons are displayed. Everything else uses as expected...

Any help is greatly appreciated

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?

Server side pagination problem

$
0
0

INTRO
I ran into strange problem: my datatable is showing "Showing 11 to 10 of 10 entries " which is obviously nonsense. I think this could be kind of bug.

I am using PHP server side processing, stateSave: true, resetDisplay: false, processing: true, serverSide: true and some others which I believe are not important.

Let's assume I am showing just some active data, 11 records in total, page length 10 rows => 2 pages withou filter.
When I go to some editation form directly from datatable **second ** page and deactive one record and go back, I am getting message you can see above. AJAX parameters are start:10 and length:10.

Obviously, datatable tries to load / thinks I am still on second page which "doesn't exist" anymore.

The question is how can I handle this. I can handle it on server side like:


if (filteredCount === offset) {
offset = 0;
}


but I am still getting bad message. Thx for your thoughts!

DataTables controller only works on local host IIS express

$
0
0

Hi there,
Currently using asp net core 2.1 and works fine when running iis express but when I deploy my app to an azure hostEd app service. The DataTables controller no longer works possibly due to connection string Or some encryption occurring tho not to sure ?? As it gives the error tn/7 with an error 404 status URL not found on the DataTables controller with the Ajax request.
Cheers


Export to Google sheet

$
0
0

There must be a way to get the CSV or EXCEL export buttons to open the download in a Google sheet on an iPad. I hope that’s just something I’m missing. Would be really bad news if this couldn’t be arranged. If Apple blocks that, we need a website and letter writing campaign to ask Tim Cook to fix that.

Rename the buttons label

$
0
0

Hi, I would like to change the names of the buttons.

for example, instead to say: New Edit Delete, Should say: "New User" "Edit User" Delete User"

thank you

search field Editor datatable questions

$
0
0

first question: how search field work on server-Side when get the data from editor database function? did the search field search on all columns?
second question: if i have table that get data from other function that return json how i can make the search work as with the editor database return json function?
third question: when using server-side with editor datatbase function, i get this message when try to search input:

DataTables warning: table id=example - Unknown field: ServiceType (index 5)

if i make server-side= false the search input works fine

thanks

I want to assign function and parameters to results

$
0
0

The above images show a table row then a child row which get results from ajax. I'm printing whole table instead of json because i want to assign function to each of the numbers then show specific results (more details).

Param1 will be manager id and Param2 will be status like which counter details to show, like in the image Active has count of 203, so when i click on 203 it pass parameters to function then send another ajax call to show more details in modal.

So how to make work with json with function/parameters ?

Make table fit the size of the screen when adding vertical scroller

$
0
0

To add scrollers to my Datatable I'm currently using:

scrollY: '50vh',
scrollX: true,

I'm using vh in order for the table header to always be visible when scrolling vertically. The problem is that the height of the table will change a lot according to how much data is in the table. I need a way for the table height to always be as long as the size of the browser window. Is there a way of doing this?

Viewing all 81908 articles
Browse latest View live


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