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

How to pass parameters if server side processing is true?

0
0

The html code I have written so far is:

    $(document).ready(function () {
        $.ajax({
            "url": "Handlers/jQueryDatatableHandler.ashx",
            "data": { Operation: 'EmployeeList', searchText: '' },
            success: function (data) {
                json = JSON.parse(data);
                columns = [];
                // build column titles
                for (var i = 0; i < json.colnames.length; i++) {
                    columns.push({ title: json.colnames[i] });
                }

                var table = $('#example').DataTable({
                    "responsive": true,
                    "processing": true, 
                    "serverSide": true,
                    "order": [[4, 'desc']],
                    data: json.rows,
                    columns: columns,
                    columnDefs: [
                        {
                            targets: 0,                           
                            render: function (data, type, row) {
                                if (type === 'display') {
                                    return '<input type="checkbox" class="editor-active">';
                                }
                                return data;
                            },
                            className: "dt-body-center",
                            "orderable": false,
                            "searchable": false
                        },
                        {
                            targets: 1,
                            visible: false
                        },
                        {
                            targets: -1,
                            visible: false
                        }
                    ]
                });
            }
        });

jQueryDatatableHandler.ashx code

  public class DatatableInboxResults
  {
    public int draw { get; set; }
    public int recordsTotal { get; set; }
    public int recordsFiltered { get; set; }
    public List<string> colnames;
    public List<string[]> rows { get; set; }
  }

private string BuildDatatableResults()
{
    EmployeeListParameters mlp = new EmployeeListParameters();       
    mlp.numberOfRows = rowsCount; //not sure how to pass this value
    mlp.pageIndex = pageIndex; //not sure how to pass this value
    mlp.sortColumnName = sortColumnName; //not sure how to pass this value
    mlp.sortOrderBy = sortOrderBy; //not sure how to pass this value       
    mlp.searchText = searchTxt;

    DatatableInboxResults result = new DatatableInboxResults();
    result.colnames = new List<string>();

    result.colnames.Add(" ");
    result.colnames.Add("EmployeeId");
    result.colnames.Add("Name");
    result.colnames.Add("Title");
    result.colnames.Add("Joining");
    result.colnames.Add("Viewed");

    int totalRecords;
    int colCount = result.colnames.Count;;
    List<string> rows = new List<string>();
    result.rows = new List<string[]>();
    EmployeeViewerDataProvider mvdp = new EmployeeViewerDataProvider ();
    List<NEmployee> empList;
    msgList = mvdp.GetEmployeeDetails(mlp, out totalRecords);

    foreach (NEmployee msg in empList)
    {
        string[] row = new string[colCount];

        row[0] = "0";
        row[1] = msg.EmployeeId.ToString();
        row[2] = msg.Name;
        row[3] = msg.Title;
        row[4] = TimeZoneInfo.ConvertTimeFromUtc(msg.TimeSent, tinfo).ToString();
        row[5] = msg.Viewed.ToString();

        result.rows.Add(row);
    }
    result.recordsTotal = (Convert.ToInt32(totalRecords) + Convert.ToInt32(mlp.numberOfRows) - 1) / Convert.ToInt32(mlp.numberOfRows);

    return new JavaScriptSerializer().Serialize(result);
}

This is working fine if I set serverside processing to false but when I make it true there are certain errors. Can someone please help me or suggest how to pass/send parameters in the code so it works fine.

Please advise how to do this.


DataTables warning: table id=tblClient- Invalid JSON response

0
0

Can any one help me on this? when i try to reload datatable using $('#tblClients').DataTable().ajax.reload(); i'm getting this error

Server-side Datatables with Flask

how to use datatable to get data from mysql and nodejs

0
0

i am making web application using node js i want display data from mysql to datatable

Table Local Storage Data reload

0
0

I want to update my data in my table when a value changed in my firebase database. I'm a beginner and have no idea how to do that, and after a long unsuccessful search on the forum i need your help ;)

Here is my code:

     var table = $('#datatables').DataTable({ 
                dom: 'lBfrtip',
                responsive: true,
                data: $.map(localSave, function (value, key) {
                        return value;
                    }),
                columns: [
                    { data: "c1", render: editIcon },
                    { data: "c2", render: editIcon },             
                    { data: "e1", render: editIcon },             
                ], 
                select: true,            
                buttons: [
                    { extend: 'create', editor: editor },
                    { extend: "edit", editor: editor },
                    { extend: "remove", editor: editor },
                    {
                        extend: 'excel', text: 'Excel', exportOptions: {
                            modifier: {
                                page: 'current'
                            }
                        }
                    },
                    {
                        extend: 'pdf', text: 'Pdf', exportOptions: {
                            //modifier: { page: 'current'}
                        }
                    },
                    {
                        extend: 'print', text: 'Drucken',
                        autoPrint: true
                    },
                    {
                        extend: 'copy',
                        text: 'Kopieren',
                    }
                ],
            });

            var userId = this.userDetails.uid;
            this.db.database.ref("db link...").once('child_changed').then(function (snapshot) {
                if (snapshot.exists) {

                    localSave = snapshot.val();
                    localStorage.setItem(savePlace, JSON.stringify(localSave));

                   //Here I would like to update the table
                }
            });

How to delete multiple rows by selecting the checkboxes of a column

0
0

i want to delete selected rows from the datatable

<script>
    $(document).ready(function () {
        $.ajax({
            "url": "Handlers/jQueryDatatableHandler.ashx",
            "data": { Operation: 'GetMessages', searchText: '' },
            success: function (data) {
                json = JSON.parse(data);
                columns = [];
                // build column titles
                for (var i = 0; i < json.colnames.length; i++) {
                    columns.push({ title: json.colnames[i] });
                }

                var table = $('#example').DataTable({
                    "responsive": true,
                    "processing": true, 
                    "serverSide": false, 
                    "order": [[4, 'desc']],
                    data: json.rows,
                    columns: columns,
                    columnDefs: [
                        {
                            targets: 0,
                            render: function (data, type, row) {
                                if (type === 'display') {
                                    return '<input type="checkbox" class="editor-active">';
                                }
                                return data;
                            },
                            className: "dt-body-center",
                            "orderable": false,
                            "searchable": false
                        },
                        {
                            targets: 1,
                            visible: false
                        },
                        {
                            targets: -1,
                            visible: false
                        }
                    ],
                    "lengthMenu": [2, 4, 8]
                });
            }
        });


        $('#example').on('click', 'tbody tr', function () {
         //do something   
        });
    });

    $('.editor-active').click(function () {          
        var table = $('#example').DataTable();
        var row = table.row($(this)).data();
        console.log(row);             
    });

    var buildstring = [];
    function BuildDeleteString(elem, id) {
        if ($(elem).is(':checked')) {
            if (buildstring.indexOf(id) == -1) {
                buildstring.push(id);
            }
        }
        else {
            var idx = buildstring.indexOf(id);
            if (idx != -1) {
                buildstring.splice(idx, 1);
            }
        }
    };

</script>

My first column is a checkbox column. I am doing something on row click and when I select the checkbox it fires the rowclick event and not the checkbox event.

I want to exclude the first column from the row click, how can i do that?

I want to call the 'BuildDeleteString' function whenever a checkbox is selected or unselected to store selected EmployeeId's so that on delete button click I can delete all the ids from the database.

Also I want to delete all the selected rows from the database and rebind the datatable, can you provide some example for this?

Laravel Eloquent - Options for fields of select type

0
0

Hi, I have a BollaAcquisto model that have a foreign key 'fornitore_id' in Fornitore table.
In laravel, I have defined that relationship:

public function fornitore(){ return $this->hasOne('Modules\Prodotto\Entities\Fornitore', 'id'); }

In query() function of BollaDataTable class, I have:

public function query(BollaAcquisto $model) { return BollaAcquisto::with('fornitore')->select('bolla_acquisto.*'); }

When I show the datatable, I have the fornitore.nome instead of fornitore_id, right.
The fornitore.nome field, in the editor, have type=select, so I would select the fornitore_id value from Fornitore table.

If I click on the select, no options are shown. So, how I can specify the options to Datatables editor?

Thanks a lot

LoopBack extension

0
0

Hello,

I'm using as backend LoopBack.

So far I am able to cover most cases but I have a problem with the responses of LoopBack since they do not comply with the client/server protocol Editor.

Is there a plugin that covers that? Or does anybody had some experience with that?


Why Datatables is trowing error "Cannot read property 'aDataSort' of undefined" when i destroy old i

0
0

When my datatable is initialized for the first time it works everything well. Then i need to reinitialize the table to populate with the new data it throws error "Cannot read property 'aDataSort' of undefined". Here is my code:

      initDt( pT, pOptions ) {

            if ( $.fn.dataTable.isDataTable( pT ) ) {
                $( pT ).DataTable().destroy();
                let table = $( pT ).DataTable( {
                    dom: 'Bfrtip',
                    responsive: true,
                    paging: true,
                    buttons: [
                            'copy', 'csv', 'excel', 'pdf', 'print'
                    ],
                    "scrollY": "320px"
                } );
            } else {

                let table = $( pT ).DataTable( {
                    dom: 'Bfrtip',
                    responsive: true,
                    paging: true,
                    buttons: [
                            'copy', 'csv', 'excel', 'pdf', 'print'
                    ],
                    "scrollY": "320px"
                } );
            }
        }

I've also tried to pass destroy: true in the options but the error appears the same.

The table is destroyed, when i initialize it again its when the error is being thrown.

How can i solve this?

Template bug ?

0
0

Hello,

I have a problem, the template work only if i "update" line.

When i load page

When i updated

Have you an idea ? Thanks

field processing indicator puzzle

0
0

I am wondering whether there might be a conflict between having bootstrap loaded and using the default display controller (lightbox). The page was previously developed without bootstrap styles, works without problems without bootstrap, and I do not want to change the current setup as lightbox is fine and looks good.

The problem I am running into is that for some strange reason, the field processing indicator for one of the fields is active when a record is opened in editor. The field, that the field processing indicator is active for, is the one field with a dependency.

I was able to turn the field processing indicator off (see below), but I am wondering why I am encountering this problem.

Mainly I want to make sure that there is no bigger problem that I should be aware of. Is there a list of known issues relating to loading bootstrap and using the lightbox display controller?

Thank you for your kind feedback,
Beate

editor.dependent( 'resolve', function ( val,data ) {
   if (data.row.resolve == "Y") return {
        messages: {'resolve':'<span class="spit">'+data.row.resolvestatus+'</span>'}
   };
    /* get rid of field processing indicators! */
    var prcssInds=$('.DTE_Processing_Indicator');
    for (var i=1; i<prcssInds.length; i++) {
        if (prcssInds[i].outerHTML.indexOf("field-processing") >= 0) {
            prcssInds[i].style.display="none";
        }
    }
});

How do I fill the info field with server information

0
0

Hello people,

I would like to enter an information in the same position as "table_info". The entry should contain the server time. Since the server time unfortunately can not be queried by Javascript, I had the idea to jquery them via PHP script. My problem now is that I do not get the info in the field. It is certainly because it is asyncron but how can i solve it?

Here is a detail:

$.getJSON('./update.php', function(data) {
    console.log(data); <- I need this information in the info field.
});                                                     |
                                                        |
                                                        |
$(document).ready(function () {                         |
    var table = $('#table').DataTable({                 |
        "infoCallback": function (response) {           |
            <- here ------------------------------------+
        }
    });
});

Many thanks in advance.

How to show dynamic table to datatable?

0
0

Hi everyone

I have some table in database, with not fix column in every table. Every table have very large dataset. I make feature in my website so that user can choose what table they can show. So, how can I using datatable to show tables as user choice? I hope this can use server side processing, but with dynamic table (because the columns of every table is different).

Thank you

Ultimate Datetime-Moment plugin not working!!!

0
0

Hi,
I can't get the ultimate plugin (https://datatables.net/blog/2014-12-18) work for my site.
I have datetime column.The input for the column (eisodos) from JSON is 'dd/MM/yyyy HH:mm:ss' e.g. 31/10/2018 10:03:00
The field in SQL Server is Datetime.In query.php ,i FORMAT it to 'dd/MM/yyyy HH:mm:ss' and encode to JSON.

If i FORMAT it to 'yyyy/MM/dd HH:mm:ss' it sorts fine in the Datatable,but i want 'dd/MM/yyyy HH:mm:ss' .

I include both scripts (latest versions) :

                  <script src="bower_components/moment/min/moment.min.js"></script>

and

                  <script src="bower_components/moment/min/datetime-moment.js"></script>

I have checked everything.

The result i get when i sort is:

I have been searching two days and i can't find a solution.
Can you help me?

Here is my code:

   $(function () {
   $.fn.dataTable.moment( 'dd/MM/yyyy HH:mm:ss' );

   var table = $('#example').DataTable({

   ajax : { url: "query.php",  dataType: "json", dataSrc: '' },
   "columns": [
         { "data": "eisodos" },
        // I have also tried the following (column render) but nothing changed.
        // "render": function(data, type, full) {return moment(data).format('dd/MM/yyyy HH:mm:ss'); }   
               ] ,
     "language": { "url": "Greek.json" }

      });
      });

How can I implement the inheritance of the layout of the dataTable when printing

0
0

I have columns containing combination of 2 or more values. I used this function to combine these values into 1 column

{"mData": function (data, type, dataToSet) {
                        return data.ticket.accountName + " <br>" + data.ticket.address + " <br>" + data.ticket.accountNumber + "&emsp;" + data.ticket.meterNumber + " <br>" + data.ticket.contactNumber;
                    }},

The layout is working in dataTables but when I print the dataTable, the "<br>" is removed making the layout destroyed


China the water glass manufacturers

0
0

XI`AN NEW LINK INTERNATIONAL TRADING CO.,LTD is a manufacturer and trader more than 15 years, we specialized in the research, development and production of high quality crystal glassware and hand made glassware, with convenient transportation access. All of our products comply with international quality standards and are greatly appreciated in a variety of different markets throughout the world.
If you are interested in any of our products or would like to discuss a custom order, please feel free to contact us. We are looking forward to forming successful business relationships with new clients around the world in the near future.China the water glass manufacturers
website:http://www.7glassware.com/

Customized Men's T-Shirt

0
0

Men's Fashionable Tight Fit Short-sleeved Cotton T-Shirt With Printed Logo
Product Type: T-Shirt
Supply Type: OEM Service
Material: cotton
Available Sizes: XXS, XS, S, M, L, Xl, XXL, XXXL
Color: Customized
Fabric Weight: 80-240 grams
Gender: Men
Collar: O-Neck
Logo: Printed or Embroidered
Season: Spring, summer
Sleeve Style: Short Sleeve
Age Group: Adults
Category: Printed t-shirt
Style: Causal
Delivery:
1.We deliver timely base on our contract.
2.We have professional logistic partners covering express, air and Sea shipping.
3.Assigned shipping company is welcome.
FAQ:THIS FAQ CONTAINS VERY VALUABLE INFORMATION. PLEASE SPEND SOME TIME AND READ CAREFULLY!
Q:What is the lead time for samples?
A:3-10 days depending on complexity of sample requirements.
Q:Do you provide free samples?
A:We charge reasonable sample fees. And the freight cost for samples will be undertaken by the customer.
Q:What’s your payment term?
A:T/T, Paypal payment are accepted
Q:Where do you export?
A:Worldwide.
Q:What’s your delivery term?
A:FOB Shenzhen or EX-work Factory.
Q:What is the lead time for mass production?
A:7 days to 2 months or above depending on quantity of bulk order.
Our strength:
1.Low MOQ - This meets different business requirements.
2.Good Service - We value every chance of business cooperation with potential customers, no matter big or small.
3.Good quality - Strict double-check QC process including both online and final check guarantees the quality of mass products.
4.Fast and timely delivery–More than 10 years of OEM experience enables us to make professional and flexible production plans which guarantee fast and timely delivery.
Need more information? Contact us NOW!
Founded in 2005, Gangya Garment, one of the leading apparel and accessories manufacturers and suppliers, now brings you high quality men's fashionable tight fit short-sleeved cotton t-shirt with printed logo. Having been constantly innovating and improving, you can rest assured to find well-designed clothes from our factory and try our customized service.Customized Men's T-Shirt
website:http://www.gangyagarment.com/t-shirt/men-s-t-shirt/

Customized air conditioner swing motor

0
0

ZHEJIANG KENING MOTOR CO.,LTD. (Formerly known as HUZHOU JIALI MACHINE AND ELECTRIC TECHNOLOGY CO., LTD.)is a technological private-owned enterprise, which is specializing ed in the manufacture of household electric motors. The company is located in Nanxun which is famous for the motor production and enjoys convenient transportation. The company factory covers an area of 45000 square meters, plant area of 66000 square meters. It has a total staff of 800, including more than 120 technology and quality management personnel. The company has 200 million RMB in fixed assets,more than 100 sets of domestic leading specialized electrical equipment, more than 30 sets of advanced test equipment, including coordinate measuring instruments, roundness meters, projectors, ROHS spectrometers, terminal analyzers, and other domestic leading testing equipment and so on . The company's products support all types of washing machines, including Twin tub washing machine motors, Top load automatic washing machine motors, universal motors for roller washing machines, BLDC motors, brushless DC motors, three-phase variable frequency motors, air-conditioning motors and other motors. The annual production capacity up to 12 million pcs, including 2 million pcs of universal motors and the BLDC motors. The company's main customers include Midea Group, Little Swan , TCL , Whirlpool, Konka, Ningbo Qishuai, Hyundai, Videocon, Electrolux, and so on. In the Meantime, the company is the only one motor R & D and production station of "China National Electric Apparatus Research Institute Co.,Ltd".
First-class production equipment and sophisticated test equipment is the premise of producing quality products; a sound quality management system and a lean production management team are the guarantee of quality products. Technological innovation and modern management is the principle that the company adheres to. The company has fully implemented the ISO9001: 2008 quality system in quality management, in addition to the advanced TS16949 quality system. All products have passed the China Quality Center CCC certification; some products have obtained the CE, CB, Saudi SASO, Mexico NOM certifications. The company's products also won such honorary titles as "Huzhou Famous Brand Products", "Huzhou Key Enterprise", "Huzhou Invisible Champion Industrial Enterprise". "Nanxun District Government Quality Award", "Huzhou Fine Management Demonstration Enterprise". "A company without innovation is a soulless enterprise". Since the inception, the company has insisted on technological innovation, continuously upgrading their design and development capabilities.Now we have 3 invention patents and 15 utility model patents. In 2014, the company set up a special DC inverter motor research and development team, having developed two series of DC inverter motors for Pulsator and front load washing machines, which have been started mass production. At the same time, the company was rated as "High-Tech Enterprise In Zhejiang", "Province-Level Research And Development Center of High-Tech Enterprise In Zhejiang" and other honors. We adhering to the corporate philosophy of "professionalism, integrity, teamwork, innovation, transcendence", and also we insist on scientific and technological innovation. By virtue of "creating quality products through all-member improvement, and promoting development through large-scale profits", we strive to build a leading enterprise in the domestic electrical industry, and an excellent washing machine electrical supplier worldwide, to provide customers with satisfactory products and services, to for the revitalization of the national industry, to make much more contributions to the goal of "intelligent manufacturing in China".

Customized air conditioner swing motor
website:http://www.kening-chinas.com/

Problem with SQL AND in Leftjoin - wont write

0
0

Hi

I am a complete hack when it comes to this sort of thing, but have spent a couple of days trying to solve this problem.

I have a Questions table and Responses Table.

Responses is Left joined to Questions and I have this statement to return all records from Questions and the records from Responses WHERE the Response belongs to the User - pretty simple stuff.

->leftJoin('checklist_responses_tbl', 'checklist_responses_tbl.checklist_question_id' , ' = ', 'checklist_questions_tbl.checklist_question_id AND (checklist_responses_tbl.checklist_assignment_id = "'.$thisUser.'")')

However, the DataTable shows up fine (I can see all the questions, and the responses that $thisUser has submitted) but when I update a value to Responses, the update fails (If I update a Questions value it succeeds)

I cant work out where i am going wrong. Any help would be greatly appreciated.

BUG: Responsive doesn't adjust page navigation bar to fit to screen.

0
0

Not sure how to post this as a bug report.

Step 1: https://jsfiddle.net/q0p5yo2e/
Step 2: Adjust the column so the right side is 400px or less
Step 3: Click run

The adjust page navigation bar is too large and prevents the page from properly fitting on the screen. This is a problem for all mobile users and Google flags this as a mobile unfriendly page.

It could be fixed by displaying less page numbers.

Viewing all 79323 articles
Browse latest View live




Latest Images