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

datatables serverside edit button not working on smart phone only?


Sorting natural-nohtml not working

$
0
0

Hello,

i need to sort column 0 "Názov" as string. By default type its not working. I tried natural-nohtml but still not working. Here is screenshot of preview or sort.

My wrong sort:
IMG_20180727_121030.jpg
IMG_20180727_140931.jpg
IMG_20180727_115842.jpg
IMG_20180727_120503.jpg
IMG_20180727_145237.jpg

Right sort is:
IMG_20180727_115842.jpg
IMG_20180727_120503.jpg
IMG_20180727_121030.jpg
IMG_20180727_140931.jpg
IMG_20180727_145237.jpg

Here is example with few rows:
https://pastebin.com/CyL4h3zJ

Here is my script definition of table:
https://pastebin.com/B8LERv58

Here is the test case:
http://live.datatables.net/mafoyeja/1/

Thank you for any advice.

does datatable editor work with html template as a datasource instead of json??

$
0
0

i want to provide as an html as datasource instead of html

How to display Paging info inside paging buttons?

$
0
0

How to display Paging info inside paging buttons?
e.g. << < 1 - 10 of 25 > >>

Possible to limit data based on specific link table field value?

How to search Row Details

$
0
0

I'm setting up a table and using the Row details to show a lot more information that is available in the visible columns. The row data and the details data are coming from REST calls and are available when the table is presented to users -- no additional calls or anything fancy when the details row is displayed.

I've also got the search set up and it is working, but my users need to be able to search the contents of the details row as well. I would like to integrate that into the basic search -- that is I would prefer not to create another search mechanism.

Is there a way out of the box to include all the row data in the search?

One thought I had was adding a hidden searchable column to the table. There are about 15 to 20 different pieces of data in the details display so that could get messy.

Any other ideas how to do this?

Editor buttons - How to disable columns in a multiselect edit button?

$
0
0

I use select and have a collection button ... where I call the edit function to edit the selected records like this:

...
{
extend: 'collection',
text: 'Select',
buttons: 
{
    extend: 'selectRows',
    text:   'Select Rows'
}, {
    extend: 'selectNone',
    text:   'Deselect All'
}, {
    extend: 'edit',
    text:   'Edit selected',
    action: function ( e, dt, node, config ) {
        var rows = table_books.rows( '.selected' );
        rows
            //.disable( 'books.name' )
            .edit({
            title: 'Edit Records',
                buttons: [
                ...
              ]
        });     


       }
  }]
}
...

In general it works ... but when I want to disable a column ... //.disable( 'books.name' ) ... I'm getting:

console error:

TypeError: rows.edit(...).disable is not a function

What am I missing? And how to disable columns in a multiselect edit button?

columns.data documentation suggestion

$
0
0

Hi,

I got a little confused by columns.data documentation when data is provided by a function.

The description of type argument from signature data( row, type, set, meta ) is not very informative ("The data type requested for the cell")

I understand type is somewhat of an enum described in the Orthogonal data page, but I had to dig into the forum and cross information to get this.

Couldn't the documentation be updated with something like "The data type requested for the cell as described in Orthogonal data" ?


Filter the list in a combobox

$
0
0

Hi,
I want to filter the list in a combobox, from a datatable editor. When I use the where condition, I do not have any errors, but it does not return any records.

Editor::inst( $db, 'tb_diccionario' )
->field(
Field::inst( 'tb_diccionario.materia_id' )
->options( Options::inst()
->table( 'tb_materia' )
->value( 'id' )
->label( 'materia' )
->where( 'tb_materia.activo', 1 )
),
Field::inst( 'tb_materia.materia' ),

->leftJoin( 'tb_materia', 'tb_materia.id', '=', 'tb_diccionario.materia_id' )

*Activo es un campo de la tabla materia de tipo tinyint.

Inline edition event after editing

$
0
0

As the user change a field, I need another field to be updated.
It works well using a listener in the edition form:

$( 'input', editor.field( 'ds_pluv' ).node() ).on( 'change', function (e, d) {
if ( ! d || ! d.editor ) { // Used to be sure change is fired from the form (not inline editing)
editor.field( 'ds_cor_pluv' ).val(true);
}
} );

But when inline editing, this appears not to be working.
Is there any other way to be able to trigger a specific action after inline editing a cell ?

Xavier

Datatables not working when having nested asp:ListView?

$
0
0

Hey everyone, first time poster here. I just started using Datatables and i love it. I do however have a problem i cant seem to find a solution for. I have a parent listview with a table, when i click a button in a row, i fetch data and populate the nested listview and table, like an accordion.

Datatable javascript:

$("#tbl_MainProj").DataTable({
                fixedHeader: true
                , bLengthChange: false
                , bPaginate: false
                , searching: false
                , targets: 'no-sort'
                , bSort: true                    
            });

aspx.:

<asp:ListView ID="ListV_Proj" runat="server" DataSourceID="Project_ObjectDataSource" OnItemCommand="ListV_Proj_ItemCommand">
                        <LayoutTemplate>
                            <table id="tbl_MainProj" class="gvv">
                                <thead>
                                    <tr>
                                        <th>
                                            <asp:Label Text="Sub" runat="server" />
                                        </th>
                                        <th>
                                            <asp:Label Text="Nummer" runat="server" />
                                        </th>
                                        <th>
                                            <asp:Label Text="Konto" runat="server" />
                                        </th>
                                        <th>
                                            <asp:Label Text="Navn" runat="server" />
                                        </th>                                       
                                        <th>
                                            <asp:Label Text="Status" runat="server" />
                                        </th>
                                    </tr>
                                </thead>
                                <tr id="itemPlaceholder" runat="server" />
                            </table>
                        </LayoutTemplate>
                        <ItemTemplate>
                            <tr runat="server">
                                <td>
                                    <asp:Button ID="btn_GetSubProj" Text="+" runat="server" CommandArgument='<%# Eval("Proj") %>' />
                                </td>
                                <td>
                                    <asp:Label ID="lbl_projNo" Text='<%# Eval("Proj") %>' runat="server" />

                                </td>
                                <td>
                                    <asp:Label Text='<%# Eval("ACCOUNT") %>' runat="server" />

                                </td>
                                <td>
                                    <asp:Label Text='<%# Eval("NAME") %>' runat="server" />

                                </td>                             
                                <td>
                                    <div id="rgy" class='<%# CalcDateExceed(Eval("END_", "{0:d}")) %>'></div>
                                </td>
                            </tr>
                            <tr>
                                <td>
                                    <asp:ListView ID="ListView_subProj1" runat="server">
                                        <LayoutTemplate>
                                            <table id="tbl_subProj1">
                                                <thead>
                                                    <tr>
                                                        <th>
                                                            <asp:Label Text="Nummer" runat="server" />
                                                        </th>
                                                        <th>
                                                            <asp:Label Text="Konto" runat="server" />
                                                        </th>
                                                        <th>
                                                            <asp:Label Text="Navn" runat="server" />
                                                        </th>                                                       
                                                        <th>
                                                            <asp:Label Text="Status" runat="server" />
                                                        </th>
                                                    </tr>
                                                </thead>
                                                <tr id="itemPlaceholder" runat="server" />
                                            </table>
                                        </LayoutTemplate>
                                        <ItemTemplate>
                                            <tr runat="server">
                                                <td>
                                                    <asp:Label ID="lbl_projNo" Text='<%# Eval("Proj") %>' runat="server" />

                                                </td>
                                                <td>
                                                    <asp:Label Text='<%# Eval("ACCOUNT") %>' runat="server" />

                                                </td>
                                                <td>
                                                    <asp:Label Text='<%# Eval("NAME") %>' runat="server" />

                                                </td>                                              
                                                <td>
                                                    <div id="rgy" class='<%# CalcDateExceed(Eval("END_", "{0:d}")) %>'></div>
                                                </td>
                                            </tr>
                                        </ItemTemplate>
                                    </asp:ListView>
                                </td>
                            </tr>
                        </ItemTemplate>
                    </asp:ListView>

Codebehind:

protected void ListV_Proj_ItemCommand(object sender, ListViewCommandEventArgs e)
    {
       
        DataTable subProTable = uWeb.Data.Project.List_Test("", null, null, null, null, null, null, null, null, null, false, 
        e.CommandArgument.ToString());       
        ListView subListV = (ListView)e.Item.FindControl("ListView_subProj1");
        subListV.DataSource = subProTable;
        subListV.DataBind();             
    }

I only need the Datatable functionality on the parent listView(Table). But the row containing the child listView is throwing the jQuery exception:

"Unable to set property '_DT_CellIndex' of undefined or null reference".

Is there any way to solve this and keep the functionality of datatables?

I think have to use below script somehow. But i cant seem to figure it out.

"aoColumnDefs": [{
  "aTargets": [2,3,4,5],
  "defaultContent": ""
}]

Change text color based on value

$
0
0

I'm trying to work out some conditional formatting for column 4 and 5, based on these criteria:

if value <= 0, color here
if value => 1, color here
if value => 2, color here
if value => 3, color here
if value => 4, color here
if value => 5, color here

I've read I need to use rowcallback in order to use this, but I can't get my head around it.

Best regards

Datatables Training

$
0
0

Our company started using datatables last year. The product is impressive. However our knowledge of how to use it efficiently with server-side processing, JSON, PHP and AJAX is severely lacking which hurts in producing large reports. Is there a place we can go to find an expert to train our staff on how to use the product effectively? Thanks for your help!

row-reordered event issue

$
0
0

Hi all,

I'm try to use row-reordered event to do some calculate on the data.
The event is fired, and call an external js function.
In this function, I call o.DataTable().rows();
The result is the data ordered as before the reorder, not after ...

How can I trigger an event after the reorder ?

Thanks,
Yannick

How To add Edit And Delete Button to the Dynamically Created Column to each rows

$
0
0

I am Having JSON object from which i am creating Dynamic Columns. At 5th position i am having ID which i want to pass to Server. How do i achieve it on click of specific button

 var jsonData=data[key[0]];
 var column=data[key[1]];

 $('#example').DataTable({
          data: jsonData,
          columnDefs: [
                {
                    targets: 5,
                    render: function(data, type, full, meta){
                       if(type === 'display'){
                          data = 
                              '<button class="btn-edit" type="button">Edit</button>'
                              + '<button class="btn-delete" type="button">Delet</button>';
                       }

                       return data;
                    }
                }       
            ],
         columns: column
     });

Dealing w/ Large JSON Files

$
0
0

We're leveraging DataTables to consume a single json file containing static code analysis results, which can grow quite quickly (in some cases 10+ MB). This is achieved leveraging the "ajax" parameter w/in DataTables...code can be found here:

https://github.com/ninp0/csi/blob/master/lib/csi/reports/scapm.rb#L149

Needless to say when the json file is large it takes quite a long time for the DataTables UI to load (in the event it ever loads). Is there a way to load the JSON file incrementally (based upon pagination) or consume multiple smaller json files which can then be incrementally displayed? I hope this question makes sense (as I'm not thoroughly caffeinated yet).

editor edit().submit not waiting for ajax loaded options

$
0
0

Hi,

It's quite a complex issue but i will try my best describing it. Unfortunatelly I cant setup a test site- since it is for internal use only.
Using editor with some fields of select2 ajax type.

They are all similar ,but ill put one as an example:

    fields:[{
                label: "Projekt:", name: "ProjectCardId", type: "select2", opts: {
                minimumInputLength: 3,
                allowClear: true,
                placeholder: "",           
                ajax: {
                    url: ''someurl",
                    dataType: "json",
                    async:false,
                    processResults: (data: any) => {
                        return { results: data };
                    }
                }
            }
    }....],

I have some other field that when edited i have an event listener. When triggered it will change the ReadyForSaf field and submit the changes:

    table.on("change", "tbody input.editor-readyforsaf", (e: Event) => {
                const $elem = $(e.currentTarget);
                editor.edit($tr, false, {submit: "changed"}).set("ReadyForSaf", $elem.prop("checked") ? true : false).submit();             
            });

However when submitting, the editor will still try to send some other (select2 ajax type) fields that were not changed. Like ProjectCardId even though the data for this was loaded with the initial data.

action: edit
data[75][ProjectCardId]: 
data[75][DeliveryScheduleId]: 
data[75][OutsourcerId]: 
data[75][ReadyForSaf]: true

In the browser I see that it tries to load the ajax data for the fields(select options), but it will not wait for them to complete, before it submits the edit request. This however will result in NULL-ing my data in the backend. When i Try to edit the same field the second time it still tries to load the data over ajax, but it will submit the values since it preloaded them before.
This is the image of the browser console network tab- that illustrates that it will not wait for the select2 ajax to finish.

NB!- when editing some regular text field with the inline option -it works. Since when clicking on the cell and making it editable- it actually does the select2 ajax queries and finished before i press enter or lose focus.

 table.on("click", "tbody td.editor-enable-inline", function () {
                editor.inline(dataTable.cell(this).index(), { onBlur: "submit" });

            });

Hope the description is sufficent.

BR,
Rauno

Method Destroy many datatables in same page

$
0
0

I have in my page, many tables. They are initialized with DataTables jquery with keytable plugins. When i use method $("#mytable1").DataTable().destroy()in a espefic table, all others lose keytable. Anybody know why this happing?

How to get cell data from selected columns with a paginated page and colreorder.

$
0
0

I need to build an array of 'types' in jQuery.

The types I need to populated the array are included in a datatable column, I only want to add the selected row's 'types' to the array.

If this wasn't a paginated page I could loop through all the table rows with .selected class, however, because it is this will only get the selected rows for the page you are on, missing the rest on the other pages.

I can't use table.rows( '.selected' ) because this means I need to get the data by array index, but as I am also using colReorder, this index moves around.

I can't add and remove to the array as and when the .tr is clicked because multiple rows can be deselected in one tr click.

Maybe the only way to do it is by including the type column as a non-reorderable column? But is there any other way to achieve this?

Add attribute to Column to mData function

$
0
0

Is it possible to add attribute to column when is rendering through mData function. I tried few solutions, but none of that is not correct. This last works just for first row.
There is how it looks like

At first column It has some name, and other columns has some predefined quantity if has in database. Max predefined quantities are 4.
Logic is if user click on predefined quantity than number will added to quantity, if user click at name quantity will be 1.

This is my table

var popupTable = $("#supplementSelectorGrid").DataTable({
        "scrollY": "300px",
        "scrollX": false,
        deferRender: true,
        crollCollapse: true,
        scroller: true,
        "ordering": false,
        "autoWidth ": false,
        "responsive": false,
        "stateSave": true,
        "row-border": false,
        "paging": true,
        "processing": true,
        "filter": true,
        "sServerSide": true,
        "info": false,
        "destroy": true,
        "order": false,
        "pageLength": 10,
        "language": {
            "sUrl": "/" + localIISPath + "/Content/DataTables/Localization/" + Resource.datatableLocalization + ".json",
            "sZeroRecords": SuppplementResource.noSupplementsMessage
        },
        "ajax": {
            "url": '/' + localIISPath + '/Supplement/GetSupplementsJson',
            data: function (data) {
                return "{'gender':'" + gender + "', 'supplementType':'" + supplementType + "'}";
            },
            "dataType": "json",
            "contentType": "application/json; charset=utf-8",
            "type": "POST",
            "dataSrc": function (json) {
                return json;
            }
        },
        'createdRow': function (row, data, dataIndex) {
            $(row).attr('data-id', data.Id);
            $(row).attr('data-code', data.Code);
            $(row).attr('data-name', data.Name);
        },
        "columnDefs": [
            { "width": "68%", "targets": 0 },
            { "width": "8%", "targets": 1 },
            { "width": "8%", "targets": 2 },
            { "width": "8%", "targets": 3 },
            { "width": "8%", "targets": 4 }
        ],
        "columns": [
            {
                "mData": function (data, type, dataToSet, td) {
                    return data.Name;
                }
            },
            {
                "mData": function (data, type, dataToSet, td) {
                    if (data.SupplementPredefinedQuantities.length > 0) {
                        $('#supplementSelectorGrid tbody tr td:eq(' + td.col + ')', td.row).attr("supplementPredefinedQuantity", data.SupplementPredefinedQuantities[0].PredefinedQuantity);

                        return data.SupplementPredefinedQuantities[0].PredefinedQuantity;
                    }
                    return "";
                }
            },
            {
                "mData": function (data, type, dataToSet, td) {
                    if (data.SupplementPredefinedQuantities.length > 1) {                        
                        $('#supplementSelectorGrid tbody tr td:eq(' +  td.col +  ')', td.row).attr("supplementPredefinedQuantity", data.SupplementPredefinedQuantities[1].PredefinedQuantity); 
                        return data.SupplementPredefinedQuantities[1].PredefinedQuantity;
                    }
                    return "";
                }
            }, {
                "mData": function (data, type, dataToSet, td) {
                    if (data.SupplementPredefinedQuantities.length > 2) {                        
                        $('#supplementSelectorGrid tbody tr td:eq(' +  td.col + ')', td.row).attr("supplementPredefinedQuantity", data.SupplementPredefinedQuantities[2].PredefinedQuantity);
                        return data.SupplementPredefinedQuantities[2].PredefinedQuantity;
                    }
                    return "";
                }
            }, {
                "mData": function (data, type, dataToSet, td) {
                    if (data.SupplementPredefinedQuantities.length > 3) {                      
                        $('#supplementSelectorGrid tbody tr td:eq('  + td.col +  ')', td.row).attr("supplementPredefinedQuantity", data.SupplementPredefinedQuantities[3].PredefinedQuantity);
                        return data.SupplementPredefinedQuantities[3].PredefinedQuantity;
                    }
                    return "";
                }
            },
        ]
    });

And there is function for click on column...
//click on supplements column/row to select it and add to patient supplements

$('#supplementSelectorGrid tbody').on('click', 'td', function () {

        var supplementId = $(this).closest('tr').attr('data-id');
        var code = $(this).closest('tr').attr('data-code');
        var name = $(this).closest('tr').attr('data-name');
        **var predefinedQuantity = $(this).attr('supplementPredefinedQuantity');** 
        var quantity = 1;
        if (predefinedQuantity != null) {
            quantity = predefinedQuantity;
        }     
       ....And so on...
    });
});

$('#supplementSelectorGrid tbody tr td:eq(' + td.col + ')', td.row).attr("supplementPredefinedQuantity", data.SupplementPredefinedQuantities[0].PredefinedQuantity);
This doesn't work as I expected :smile:

NOTE: I don want to get value on click because user can click on name, and i don't want to name go into quantity and secound reason is that I will add unit measure in this line with predefined quantity... something like:
return data.SupplementPredefinedQuantities[0].PredefinedQuantity.toString() + "mg";

Is there any other solution for my problem. Thank you!

Viewing all 81386 articles
Browse latest View live


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