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

How don't save upload file on disk

$
0
0

Hello,

I use DataTable editor with c#.NET library.

One on my fields it's "upload" type.
I don't want save the file in disk, I want directly save content in my DB.
What's method for this ?

This code save content on my DB and on my disk :

  var response = new Editor(db, "users")
                    .Model<UploadModel>()
                            .TryCatch(false)
                    .Field(new Field("image")
                        .SetFormatter(Format.IfEmpty(null))
                        .Upload(new Upload(request.PhysicalApplicationPath + @"uploads\__ID____EXTN__")
                            .Db("files", "id", new Dictionary<string, object>
                            {
                                {"web_path", Upload.DbType.WebPath},
                                {"system_path", Upload.DbType.SystemPath},
                                {"filename", Upload.DbType.FileName},
                                {"filesize", Upload.DbType.FileSize},
                                {"content", Upload.DbType.ContentBinary},
                            })
                            .DbClean(data =>
                            {
                                foreach (var row in data)
                                {
                                    // Do something;
                                }
                                return true;
                            })
                            .Validator(Validation.FileSize(500000, "Max file size is 500K."))
                            .Validator(Validation.FileExtensions( new [] {"jpg", "png", "gif"}, "Please upload an image."))
                        )
                    )
                    .Process(request)
                    .Data();

I try Upload(null) by don't work.

Thanks,


Ms sql decimal precision

$
0
0

Hello!
Please tell me how to set up for ms sql column decimal(12,3) three decimal part position no more in my grid.
I want to protect user to insert more decimal part.
Is it possible?
Thank you

JSONP - Link to JSON data file?

$
0
0

Hello,

I'm trying to get my head around server side loading and I'm not quite grasping the info on this page -
https://datatables.net/examples/server_side/jsonp.html

It looks to me like the Javascript links to the php file (the code in the Server Side Script tab), but nothing links to the JSON data source (the data in the AJAX tab)... Is that right?

I'm pretty comfortable with something like this (in Javascript):

    $('#example').DataTable( {
        "ajax": "url: link/to/file/data.json"
    } );

But if I want to serve the data.json file from a different server, then I add a php file to my server but how / where do I link to the data.json file? Trying to recreate the files in the example linked above gives me the error message Ajax error. For more information about this error, please see datatables.net/tn/7

What am I missing? My apologies if it's something basic; I've always been more front-end focused but I'm trying to learn a bit more back end lately

Thanks!

How do I create a link that opens editor?

$
0
0

I would like to create a login link on a page simular to the Login/Register link on this site. When the link is clicked it should open editor so a user can enter there username and password. Can someone show me some working code?

Thank you

Responsive Plugin jQuery 3.0.0 d.isEmptyObject is not a function

$
0
0

I am trying to use the responsive plugin with my mvc application. The app uses jquery 3.0.0. When i try to run the responsive plugin v 2.2.2, i receive the following error:

d.isEmptyObject is not a function. /Responsive-2.2.2/js/dataTables.responsive.min.js:19:236)

I would assume that jQuery 3.0.0 no longer supports that function? I have tried doing some research to see there is a replacement function in jquery to the isEmptyObject, but have had no luck. Is there any chance you guys (the developers of the responsive plugin) have had any luck updating the plugin to work with jQuery 3.0.0? Unfortunately, the project i am doing does require that version for other stuff.

As always thanks to everyone who works on the datatables project!

Disable Scroll To Next Row | Keytable stop scroll to next line | Stop scrolling to next row

$
0
0

Hi!

I'm using Keytable for excel-like navigation. My user wants to stop scrolling to next row once he reached the end of each row.

Currently, it is having continuous scroll if you press the right arrow key.

How to disable that?

Thanks for the help!

Edit fixed column not working

$
0
0

Dear Allan!
I see you example:https://editor.datatables.net/examples/inline-editing/fixedcolumns.html
You include ../../extensions/Editor/js/dataTables.editor.min.js, but You not include dataTables.editor.js
If I include ../../extensions/Editor/js/dataTables.editor.min (replace path for my system path) the java drop error:
dataTables.editor.min.js:1 Uncaught ReferenceError: define is not defined
at dataTables.editor.min.js:1
at dataTables.editor.min.js:1
If i include Editor-1.8.1/js/dataTables.editor.js the ../../extensions/Editor/js/dataTables.editor.min.js error dropp, but the data is loading, and I can edit not fixed column.
If I click fixed column, the input field not see, but if I type anithing, and press enter, or leave fixed column, the save is called, and the data writing in database, and next reload loading the modified data.

You can send for me the example ../../extensions/Editor/js/dataTables.editor.min.js unobfuscated source?

Order with colreorder and responsive

$
0
0

Hi,

In the jsfiddle http://jsfiddle.net/SuiteProG/9wypaern/23/ I use colreorder and responsive with 17 columns.

When I want order columns with colreorder.order, one column appear 2 times like a screen.

Does anyone have an explanation to this ?

Thanks


Footer losing all formatting when export to Excel

$
0
0

Hi,

I have a table with a tfoot, this tfoot consists of values summed up from the table above it, this means it could be a currency/percentage etc.

When using the print button option it is perfect and the formatting is in place.

When using the excel button however everything is formatted except for the tfoot which just reverts to standard text with no currency symbol, no commas, no percentage symbols etc.

Is there a way of getting these back in place?

Kevin

TypeError: nTd is undefined

$
0
0

hi there I made a very simple html page

<html>
<head>
<meta charset="UTF-8"/>
  <link rel="stylesheet" type="text/css" href="./datatables.css"/>
        <script src="./jquery-3.3.1.js"></script>
        <script src="./datatables.js"></script>
        
</head>
<body> 
<table id="tiretable" class="display" style="width:100%">
            <thead>
            <tr>
                <th>ردیف</th>
                        <th>نوع</th>
                        <th>سایز</th>
                        <th>تعداد</th>
                        <th>ویرایش</th>
            </tr>
            </thead>
            <tbody>
            <tr>
                        <td>1</td>
                <td>barez</td>
                <td>13*65*165</td>
                <td>0</td>
            </tr>
            <tr>

                                <td>2</td>
                <td>barez</td>
                <td>13*60*175</td>
                <td>0</td>
            </tr>
            <tr>

                                <td>3</td>
                <td>barez</td>
                <td>13*70*175</td>
                <td>0</td>
            </tr>
            <tr>

                                <td>4</td>
                <td>barez</td>
                <td>14*60*185</td>
                <td>0</td>
            </tr>
            <tr>

                                <td>5</td>
                <td>barez</td>
                <td>14*65*185</td>
                <td>0</td>
            </tr>
            <tr>

                                <td>6</td>
                <td>barez</td>
                <td>15*65*185</td>
                <td>0</td>
            </tr>
            <tr>

                                <td>7</td>
                <td>barez</td>
                <td>15*60*185</td>
                <td>0</td>
            </tr>
            <tr>

                                <td>8</td>
                <td>barez</td>
                <td>14*60*205</td>
                <td>0</td>
            </tr>
            <tr>

                                <td>9</td>
                <td>barez</td>
                <td>15*60*205</td>
                <td>0</td>
            </tr>
           
            <tr>

                                <td>26</td>
                <td>kavirtire</td>
                <td>14*60*205</td>
                <td>0</td>
            </tr>
            <tr>

                                <td>27</td>
                <td>kavirtire</td>
                <td>15*60*205</td>
                <td>0</td>
            </tr>
            <tr>

                                <td>109</td>
                <td>kavirtire</td>
                <td>15*60*185</td>
                <td>5</td>
            </tr>
            <tr>

                            </tr>
            </tbody>
            <tfoot>
            <tr>
                <th>ردیف</th>
                <th>مدل</th>
                <th>سایز</th>
                <th>موجودی</th>
                <th>ویرایش</th>
            </tr>
            </tfoot>
        </table>
        <script>
        $(document).ready(function() {
        $('#tiretable').DataTable();
        } );
        </script>

</body>

I have source of libraries

 saeb@PublicRelation  ~/PhpstormProjects/limit/styles  tree
.
├── DataTables-1.10.18
│   ├── css
│   │   ├── dataTables.bootstrap4.css
│   │   ├── dataTables.bootstrap4.min.css
│   │   ├── dataTables.bootstrap.css
│   │   ├── dataTables.bootstrap.min.css
│   │   ├── dataTables.foundation.css
│   │   ├── dataTables.foundation.min.css
│   │   ├── dataTables.jqueryui.css
│   │   ├── dataTables.jqueryui.min.css
│   │   ├── dataTables.semanticui.css
│   │   ├── dataTables.semanticui.min.css
│   │   ├── jquery.dataTables.css
│   │   └── jquery.dataTables.min.css
│   ├── images
│   │   ├── sort_asc_disabled.png
│   │   ├── sort_asc.png
│   │   ├── sort_both.png
│   │   ├── sort_desc_disabled.png
│   │   └── sort_desc.png
│   └── js
│       ├── dataTables.bootstrap4.js
│       ├── dataTables.bootstrap4.min.js
│       ├── dataTables.bootstrap.js
│       ├── dataTables.bootstrap.min.js
│       ├── dataTables.foundation.js
│       ├── dataTables.foundation.min.js
│       ├── dataTables.jqueryui.js
│       ├── dataTables.jqueryui.min.js
│       ├── dataTables.semanticui.js
│       ├── dataTables.semanticui.min.js
│       ├── jquery.dataTables.js
│       └── jquery.dataTables.min.js
├── datatables.css
├── datatables.js
├── datatables.min.css
├── datatables.min.js
├── jquery-3.3.1.js
├── test.html
└── test.html~

but I got this error:

jQuery.Deferred exception: nTd is undefined _fnCreateTr@file:///home/saeb/PhpstormProjects/limit/styles/datatables.js:3118:6
_fnAddData@file:///home/saeb/PhpstormProjects/limit/styles/datatables.js:2435:4
_fnAddTr/<@file:///home/saeb/PhpstormProjects/limit/styles/datatables.js:2463:11
map/<@file:///home/saeb/PhpstormProjects/limit/styles/jquery-3.3.1.js:194:11
map@file:///home/saeb/PhpstormProjects/limit/styles/jquery-3.3.1.js:443:13
map@file:///home/saeb/PhpstormProjects/limit/styles/jquery-3.3.1.js:193:26
_fnAddTr@file:///home/saeb/PhpstormProjects/limit/styles/datatables.js:2461:10
loadedInit@file:///home/saeb/PhpstormProjects/limit/styles/datatables.js:1293:6
DataTable/<@file:///home/saeb/PhpstormProjects/limit/styles/datatables.js:1318:5
each@file:///home/saeb/PhpstormProjects/limit/styles/jquery-3.3.1.js:354:10
each@file:///home/saeb/PhpstormProjects/limit/styles/jquery-3.3.1.js:189:10
DataTable@file:///home/saeb/PhpstormProjects/limit/styles/datatables.js:881:3
$.fn.DataTable@file:///home/saeb/PhpstormProjects/limit/styles/datatables.js:15135:18
@file:///home/saeb/PhpstormProjects/limit/styles/test.html:225:25
mightThrow@file:///home/saeb/PhpstormProjects/limit/styles/jquery-3.3.1.js:3534:21
resolve/</process<@file:///home/saeb/PhpstormProjects/limit/styles/jquery-3.3.1.js:3602:12
undefined


ypeError: nTd is undefined[Learn More] datatables.js:3118:6
_fnCreateTr
file:///home/saeb/PhpstormProjects/limit/styles/datatables.js:3118:6
_fnAddData
file:///home/saeb/PhpstormProjects/limit/styles/datatables.js:2435:4
_fnAddTr/<
file:///home/saeb/PhpstormProjects/limit/styles/datatables.js:2463:11
map/<
file:///home/saeb/PhpstormProjects/limit/styles/jquery-3.3.1.js:194:11
map
file:///home/saeb/PhpstormProjects/limit/styles/jquery-3.3.1.js:443:13
map
file:///home/saeb/PhpstormProjects/limit/styles/jquery-3.3.1.js:193:26
_fnAddTr
file:///home/saeb/PhpstormProjects/limit/styles/datatables.js:2461:10
loadedInit
file:///home/saeb/PhpstormProjects/limit/styles/datatables.js:1293:6
DataTable/<
file:///home/saeb/PhpstormProjects/limit/styles/datatables.js:1318:5
each
file:///home/saeb/PhpstormProjects/limit/styles/jquery-3.3.1.js:354:10
each
file:///home/saeb/PhpstormProjects/limit/styles/jquery-3.3.1.js:189:10
DataTable
file:///home/saeb/PhpstormProjects/limit/styles/datatables.js:881:3
$.fn.DataTable
file:///home/saeb/PhpstormProjects/limit/styles/datatables.js:15135:18
<anonymous>
file:///home/saeb/PhpstormProjects/limit/styles/test.html:225:25
mightThrow
file:///home/saeb/PhpstormProjects/limit/styles/jquery-3.3.1.js:3534:21
resolve/</process<
file:///home/saeb/PhpstormProjects/limit/styles/jquery-3.3.1.js:3602:12

New RowsGroup plugin: merge cells vertically (rowspan)

$
0
0

Hi, all!
I've created the new Plugin as a replacement for old fnFakeRowspan (http://datatables.net/plug-ins/api/fnFakeRowspan) plugin. It works both for standalone and server-side processing. Now it has several drawbacks but will be implemented in future.

Now it:

  • Supports nested multi grouping rows
  • Works with standalone
  • Works with server side processing
  • Initial order initialization for not groupped columns
  • Support change order while running (also multi-columns with 'Shift' button)

Please try it Live at http://live.datatables.net/bodanole/1/

and Fork or make Feature request at Github https://github.com/ashl1/datatables-rowsgroup

Example usage:

var data = [
    ['subgroupN', 'Group1', 'sub-subgroupN', 'ElementN', '2Element N'],
    ['subgroup1', 'Group2', 'sub-subgroup1', 'Element1', '2Element 1'],
    ['subgroup2', 'Group2', 'sub-subgroup1', 'Element1', '2Element 1'],
    ['subgroup2', 'Group2', 'sub-subgroup1', 'Element2', '2Element 2'],
    ['subgroup2', 'Group2', 'sub-subgroup2', 'Element3', '2Element 2'],
    ['subgroup2', 'Group2', 'sub-subgroup2', 'Element4', '2Element 4'],
    ['subgroup2', 'Group2', 'sub-subgroup2', 'Element2', '2Element 2'],
    ['subgroup3', 'Group1', 'sub-subgroup1', 'Element1', '2Element 1'],
    ['subgroup3', 'Group1', 'sub-subgroup1', 'Element1', '2Element 1'],
    ['subgroup2', 'Group2', 'sub-subgroup2', 'Element1', '2Element 1'],
    ['subgroup4', 'Group2', 'sub-subgroup2', 'Element1', '2Element 1'],
    ['subgroup4', 'Group2', 'sub-subgroup3', 'Element10', '2Element 17'],
    ['subgroup4', 'Group2', 'sub-subgroup3', 'Element231', '2Element 211'],
  ];
var table = $('#example').DataTable({
    columns: [
        {
            title: 'First group',
        },
        {
            name: 'second',
            title: 'Second group [order first]',
        },
        {
            title: 'Third group',
        },
        {
            title: 'Forth ungrouped',
        },
        {
            title: 'Fifth ungrouped',
        },
    ],
    data: data,
    rowsGroup: [// Always the array (!) of the column-selectors in specified order to which rows groupping is applied
                // (column-selector could be any of specified in https://datatables.net/reference/type/column-selector)
        'second:name',
        0,
        2
    ],
    });

colReorder not proper working on ajax Datatable?

$
0
0
  1. I initialise ajax datatable and when sorting column the colReorder reset?

  2. When apply custom filter then colReorder reset?

Search function

$
0
0

at what time the function $ .fn.dataTable.ext.search.push is called?

Select row only working on first time click of button

$
0
0

I am trying to use "select": "single" to highlight a row when either the row or a button within the row is clicked.

The full functionality is working when rows are clicked into - ie this row is highlighted and all others are not. However when the Action button is clicked, the row is only highlighted on the first occasion that the button is clicked. When the button is clicked for a second or subsequent time, the previous row remains highlighted.

Demo available here: https://codepen.io/gershco/pen/YdKWBv

How to display nested row related to each other in jquery datatable by asp.net core MVC?

$
0
0

I'm creating a news website in admin panel we need show category and subcategory into jquery Datatable. Of course, I've Implemented fetching category and subcategory from the Datatable, but I have the issue about how to show category and subcategory in jquery Datatable. I've found a link about child rows in jquery Datatable, but I didn't understand it.

https://datatables.net/examples/api/row_details.html

  public static class CategoryExtension
    {
        public static IList<CategoryDto> BuildTrees(this IList<Category> categories)
        {
            var dtos = categories.Select(c => new CategoryDto
            {
                CategoryId = c.CategoryId,
                CategoryName = c.CategoryName,
                ParentId = c.ParentCategoryId
            }).ToList();

            return BuildTrees(null, dtos);
        }

        private static IList<CategoryDto> BuildTrees(int? pid,IList<CategoryDto> candicates)
        {
            var subs = candicates.Where(c => c.ParentId == pid).ToList();
            if(subs.Count() == 0)
            {
                return new List<CategoryDto>();
            }
            foreach (var item in subs)
            {
                item.Subs = BuildTrees(item.CategoryId, candicates);
            }
            return subs;
        }
    }

    public async Task<IActionResult> GetCategories()
    {

        var categories = await _newsContex.Categories.ToListAsync();
        var subs = categories.BuildTrees();           
        return Json(subs);
    }

<link href="https://cdn.datatables.net/1.10.18/css/dataTables.bootstrap.min.css" rel="stylesheet" />
    <script src="~/js/jquery.min.js"></script>
<script src="https://cdn.datatables.net/1.10.18/js/jquery.dataTables.min.js"></script>
<script src="https://cdn.datatables.net/1.10.18/js/dataTables.bootstrap.min.js"></script>

   <table class="table table-striped table-bordered table-hover" id="table_id">
<thead>
<tr>
    <th>
        عنوان دسته
    </th>

    <th class="text-center">عملیات</th>
</tr>
</thead>

</table>

<script> function format(d) { // `d` is the original data object for the row return '<table cellpadding="5" cellspacing="0" border="0" style="padding-left:50px;">' + '<tr>' + '<td>Full name:</td>' + '<td>' + d.CategoryName + '</td>' + '</tr>' + '<tr>' + '<td>Extension number:</td>' + '<td>' + 'Hello' + '</td>' + '</tr>' + '<tr>' + '<td>Extra info:</td>' + '<td>And any further details here (images etc)...</td>' + '</tr>' + '</table>'; } $(document).ready(function () { var table = $('#table_id').DataTable({ "ajax": { url: "/Admin/Category/GetCategories", type: 'get', contentType:'application/json', dataSrc: "" }, "order": [[0, 'asc']] }); // Add event listener for opening and closing details $('#table_id tbody').on('click', 'td.details-control', function () { var tr = $(this).closest('tr'); var row = table.row(tr); if (row.child.isShown()) { // This row is already open - close it row.child.hide(); tr.removeClass('shown'); } else { // Open this row row.child(format(row.data())).show(); tr.addClass('shown'); } }); }); </script>

Colvis/Column visibility with scroll bar?

$
0
0

I have a table with a complex header (huge amount of columns). I am using the colvis button to show a list of the columns in the table and to toggle column visibility. I would to add to that list a scroll bar. I know that you can add columns to the list but I would like to add a scroll bar to facilitate to search the desired column.

I would like something like that...

It would be possible?

Thank you in advanced.

language.url and language.select.rows mismatch

$
0
0

Hi,

I use datatables (version 1.10.16) and try to set the assets in French using the Internationalisation plugins.

So on datatable init, i set:

"language": {
            "url": "../../global/language/French.json"
}

which is my local translation file. I first used the content of
//cdn.datatables.net/plug-ins/1.10.19/i18n/French.json

that is to say copied the content to my French.json file

Then it don't works, and i see English language on Datatables. If i remove

 "select": {
            "rows": {
                _: "%d lignes séléctionnées",
                0: "Aucune ligne séléctionnée",
                1: "1 ligne séléctionnée"
            } 
    }

everything is working fine (except the select rows string of course).

And if i set all this parameters directly on js file, including the select rows, everythings is also working fine (including the select rows string).

Note i also tried with new parameters names, and everythings is working fine if not using language.url

"language": {
            "processing":     "Traitement en cours...",
            "search":         "Rechercher&nbsp;:",
            "lengthMenu":     "Afficher _MENU_ &eacute;l&eacute;ments",
            "info":           "Affichage de l'&eacute;lement _START_ &agrave; _END_ sur _TOTAL_ &eacute;l&eacute;ments",
            "infoEmpty":      "Affichage de l'&eacute;lement 0 &agrave; 0 sur 0 &eacute;l&eacute;ments",
            "infoFiltered":   "(filtr&eacute; de _MAX_ &eacute;l&eacute;ments au total)",
            "infoPostFix":    "",
            "loadingRecords": "Chargement en cours...",
           "zeroRecords":    "Aucun &eacute;l&eacute;ment &agrave; afficher",
            "emptyTable":     "Aucune donn&eacute;e disponible dans le tableau",
            "paginate": {
                "first":      "Premier",
                "previous":   "Pr&eacute;c&eacute;dent",
                "next":       "Suivant",
                "last":       "Dernier"
            },
            "aria": {
                "sortAscending":  ": activer pour trier la colonne par ordre croissant",
                 "sortDescending": ": activer pour trier la colonne par ordre d&eacute;croissant"
            },
            "select": {
                "rows": {
                    _: "%d lignes s&eacute;l&eacute;ctionn&eacute;es",
                    0: "Aucune ligne s&eacute;l&eacute;ctionn&eacute;e",
                    1: "1 ligne s&eacute;l&eacute;ctionn&eacute;e"
                }  
            }
        },

Do you know what's happening ?

Regards,
Thomas

Colvis/Column visibility with scroll bar?

$
0
0

I have a table with a complex header (huge amount of columns). I am using the colvis button to** show a list of the columns** in the table and to toggle column visibility. I would to add to that list a scroll bar. I know that you can add columns to the list but I would like to add a scroll bar to facilitate to search the desired column.

I would like something like that...

It would be possible?

Thank you in advanced.

Client side row reordering issues

$
0
0

Hi, We are using DataTables to edit some data on client side, but we have issues if we use reordering option or if we delete rows.
In general we need functionality which is in this example, but on Client side
https://editor.datatables.net/examples/extensions/rowReorder

Do you have any hints how to update DataTables after we do some manipulation like deleting elements or reordering.
It would be perfect to get same example working on Client side data.

Problems recovering data volume

$
0
0

Hi Allan,
We encounter a problem when retrieving data with datatables editor when the volume of data is important.
This happens with an application and MySql database in GoDaddy, where the message returned by the server is ERR_EMPTY_RESPONSE.
Same application and database on our local servers do not cause problems.
Could you tell us what can cause this error?

Viewing all 81389 articles
Browse latest View live


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