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

Datatables warning: requested unknown parameter '0' for row '0'

$
0
0

Hello, I am a complete newbie to codeigniter and jquery, I've read or related topics possible solutions but i don't know how to implement them on my code.



<link rel="stylesheet" type="text/css" href="https://cdn.datatables.net/t/bs/dt-1.10.11/datatables.min.css"/> <script type="text/javascript" src="https://cdn.datatables.net/1.10.13/js/jquery.dataTables.min.js"></script> <script type="text/javascript"> $(document).ready(function(){ $('select').chosen( { disable_search_threshold: 10, allow_single_deselect: true } ); $('#search_results tbody').empty(); var table = $('#search_results').DataTable(); $('#search_documents_form').on('submit', function(event){ event.preventDefault(); table.clear(); $.ajax({ method: 'POST', url: '<?php echo base_url($this->uri->uri_string())?>', data: { 'search_documents': '1', 'location': $('#location').val(), 'document_type': $('#document_type').val(), 'search_terms': $('#search_terms').val() } }).success(function(data){ var result = $.parseJSON(data); if(result.length > 0){ $('.total_results').empty(); $('.total_results').append(' - ' + result.length +' results'); $.each(result, function(data){ //$('#search_results tbody').append('<tr><td>'+this.branch_name+'</td><td>'+this.document_type+'</td><td>'+this.document_name+'</td><td>'+this.document_update_date+'</td><td>'+ this.document_expiry_date +'</td><td><a href="'+this.document_path+'" target="_blank"><span class="fa fa-arrow-down"></span></a></td></tr>'); table.row.add([ this.document_branch, this.document_type, this.document_name, this.document_update_date, this.document_expiry_date, '<a href="'+this.document_path+'" target="_blank"><span class="fa fa-arrow-down"></span></a>']).draw(); }); } else { $('#search_results tbody').empty(); $('.total_results').empty(); $('.total_results').append(); $('#search_results tbody').append('<tr><td colspan="6"><center><h3>No Results</h3></center></td></tr>'); } }); }); }); </script><div class="container"> <form class="form-horizontal" id="search_documents_form" action="<?php echo base_url($this->uri->uri_string());?>" method="POST"> <input type="hidden" name="search_documents" value="1"> <div class="col-lg-12"> <legend>Search Documents</legend> <div class="panel panel-primary"> <div class="panel-heading">Search Critera</div> <div class="panel-body"> <div class="row"> <div class="col-lg-6"> <!-- Select Basic --> <div class="form-group"> <label class="col-md-4 control-label" for="selectbasic">Location</label> <div class="col-md-8"> <select id="location" name="location" class="form-control"> <option></option> <?php foreach($branches as $branch_type => $branches_by_type){?> <optgroup label="<?php echo $branch_type?>"> <?php foreach($branches_by_type as $branch_name){?> <option value="<?php echo $branch_name['branch_index']?>"><?php echo $branch_name['branch_name']?></option> <?php }?> </optgroup> <?php }?> </select> </div> </div> </div> <div class="col-lg-6"> <!-- Select Basic --> <div class="form-group"> <label class="col-md-4 control-label" for="document_type">Document Type</label> <div class="col-md-8"> <select id="document_type" name="document_type" class="form-control"> <option></option> <?php foreach($document_types as $type){?> <option><?php echo ucfirst($type['document_type']);?></option> <?php }?> </select> </div> </div> </div> </div> <div class="row"> <div class="col-lg-6"> <!-- Text input--> <div class="form-group"> <label class="col-md-4 control-label" for="search_terms">Search Terms</label> <div class="col-md-8"> <input id="search_terms" name="search_terms" type="text" placeholder="Search Terms" class="form-control input-md"> </div> </div> </div> <div class="col-lg-6"> <div class="form-group"> <div class="col-md-8 col-md-offset-4"> <button type="submit" class="btn btn-primary pull-right"> Search </button> </div> </div> </div> </div> </div> </div> </form> </div> <div class="col-lg-12"> <div class="panel panel-default" style="margin-bottom: 75px;"> <div class="panel-heading">Search Results <span class="total_results"></span></div> <div class="panel-body"> <table class="table table-bordered table-hover table-striped" id="search_results"> <thead> <th style="width: 200px;">Branch</th> <th>Document Type</th> <th>Document Name</th> <th style="width: 75px;">Updated</th> <th>Expiry Date</th> <th style="width: 50px;">Action</th> </thead> <tbody> <tr> <td colspan="6"> <center><h3>Please enter search criteria</h3></center> </td> </tr> </tbody> </table> </div> </div> </div> ``` (views code)

PLEASE HELP!


About ajax data and datatable object

$
0
0

I using a datatable that load data by ajax

var table= $('#table').DataTable({
    ajax: "server url",
    column: [ {data: 'id', title:'my id'} ]
});

ajax response is only contain id;

is that possible my datatable using below object?

function object(id){
    this.id = id;

    this.idString = function(){
       return "#" + id;
    }
}

Search only for selected option (HTML select element in column)

$
0
0

Hi! I have a HTML select element inside one of the columns. I can't figure out what should I do to make search look only for selected option, not for all of them. What should I try to perform this?
I'm using datatables 1.10.13

PHP variables passed into Field to display in Editor

$
0
0

I'd like to be able to use a PHP variable $_SESSION['username'] as the value for a field that Editor makes visible.

How can I `call out' in the PHP server side code to assign a PHP variable to a field.

What I'm trying to do is akin to;

Field::inst('username')-> XXX ($_SESSION['username'])

so the currently logged in username appears in a editor field, filled in automatically.

Can I do it ?
thanks!

Fix Columns broken on Safari

$
0
0

Hi allan,

im currently using the fixColumns plug-in and it works fine everywhere except Safari browser. Please find attached an screenshot of the wrong behaviour.

As you can see the fixed rows have the wrong size. In Firefox,Chrome and IE it works fine.

Editor - show and hide child rows

$
0
0

Is there an Editor example that shows how to hide child rows which are attached to a parent row in the host table.?

Question about mutiple select in editor

$
0
0

I have a field declare like this

label: "object:",
name: "object.field_id",
multiple: true,
separator: ", ",
type: "select",
ipOpts: [ label:"object 1", value:"1"]

since it is multiple select, when edit, how it set the default value for this field? the object is an array.

Question about process of server data

$
0
0

I am using editor with ajax that return json data
{"error":null,"data":{"0":{"item":"1"}},"fieldErrors":[],"cancelled":[]}
after it edited, the datatable is not update the item value,
do I need to create a event for after submit to update and refresh the table data myself?


Excel export - change negative currency to number?

$
0
0

Hello,

My datatable has positive and negative dollar amounts, for example:

($18,929.00)

I've been able to implement the built-in styles during the Excel button export to remove the $ from the positive numbers, but can someone help me with how to remove the $ from the negative numbers? Ideally, I'd like Excel to display this:

(18,929)

Thank you!!

Large space above the table

$
0
0

I have a large blank space above the table. I stripped everything off the page except the table and the space is still there. I found the following, the more rows my table has the larger the blank space above the table.
I'm using the standard CSS, JS, html Table provided in the Examples as I'm new to this plug-in.
Thank you in advance for your help.

<body>
<table width="100%" class="display compact" id="example" cellspacing="0" data-page-length="10">
  <thead>
    <tr>                 
      <th>Name</th>
      <th>Position</th>

Datatables export csv has unicode symbols pound symbol, how to get rid of this?

$
0
0

When i try to export a csv file which has pound symbol in one particular column,, it will get appended with "£" this character..

Kindly guide me to get rid of this.

Enable/disable column sorting event

$
0
0

How can i disable and enable sorting in datatable after generating the datatable. Suppose when select any chekbox of any row depend my datatable sorting will disable and after dselect it will again enable.

I have implement this code $('.dataTables_scrollHead thead th').off('click.DT'); it disable the sorting event. But I can not again bind the click event. Please help how can i solve the situation.

Inline editor, keys and datepicker

$
0
0

Hi,

I have an inline editor and am using keys to tab and edit data. If i have a jquery UI datepicker field and do the following -

  1. Tab into the field, the datepicker appears as expected
  2. Choose a date with the mouse
  3. Hit tab to move to the next field

the cell has lost focus so hitting tab starts tabbing through the non datatables elements on the page.

Is there any way to suppress the blur event for that field (not the table) so it stays in focus? Is there a preblur event for the cell (not the table)?

I also get this problem when using the mouse to move the scrollbar in a selectize dropdown and I'm assuming it's the same issue. Some way of suppressing the blur would be useful if available.

Thanks.

Using server side without ssp class

$
0
0

Hi Allan, hope you're doing well.
I'd like to ask you if there is any script sample for server side without the ssp class. I've noticed that I can use some GET variables such as start, length, ... but it'll be nice to have a sample.

Thanks a lot
Regards

Uncaught TypeError: Cannot set property 'data' of null in datatable

$
0
0

Hello I am fetching the records using json response from controller in MVC. All the records are returned successfully from the controller side to .cshtml page but at my view side it cannot bind data to datatable in .cshtml file and give me an error as follow.

Uncaught TypeError: Cannot set property 'data' of null
at ra (jquery.dataTables.min.js:35)
at Ub (jquery.dataTables.min.js:105)
at t.<anonymous> (jquery.dataTables.min.js:106)
at t.iterator (jquery.dataTables.min.js:97)
at t.<anonymous> (jquery.dataTables.min.js:106)
at Object.reload (jquery.dataTables.min.js:100)
at Object.complete (RejectedTransactions:697)
at l (jquery?v=aVgyEaZfAxZS60CT-VlCELEfaJJd3gsmIEC_bIC2LQQ1:1)
at Object.fireWith (jquery?v=aVgyEaZfAxZS60CT-VlCELEfaJJd3gsmIEC_bIC2LQQ1:1)
at w (jquery?v=aVgyEaZfAxZS60CT-VlCELEfaJJd3gsmIEC_bIC2LQQ1:1)

My Controller's code is as follow,

[HttpPost]
        [Authorize]
        public JsonResult GetRejectedMerchantTransactions(string mobileNumber, DateTime? fromDate, DateTime? toDate, string fromTime, string toTime)
        {
            string sMessage = string.Empty;
            bool bError = false;
            bool bStatus = true;

            List<MerchantTransactionModel> lstMerchantTransactionModel = new List<MerchantTransactionModel>();
            try
            {
                string shortFromDate = "";
                string shortToDate = "";
                string fromFinalDate = string.Empty;
                string toFinalDate = string.Empty;

                if (fromDate.HasValue && fromTime.Length > 1)
                {
                    shortFromDate = fromDate.Value.ToShortDateString();
                    fromFinalDate = shortFromDate + " " + fromTime;
                }

                if (toDate.HasValue && toTime.Length > 1)
                {
                    shortToDate = toDate.Value.ToShortDateString();
                    toFinalDate = shortToDate + " " + toTime;
                }

                List<TransactionStatusModel> lstTransactionStatusModel = GetTransactionStatusList();

                TransactionService.TransactionServiceClient transactionServiceClient = new TransactionService.TransactionServiceClient();
                TransactionService.GetRejectedMerchantTransactionsRequest getRejectedMerchantTransactionRequest = new TransactionService.GetRejectedMerchantTransactionsRequest()
                {
                    //MobileNumber = Convert.ToDecimal(mobileNumber),
                    //FromDate = !string.IsNullOrEmpty(fromFinalDate) ? Convert.ToDateTime(fromFinalDate) : fromDate,
                    //ToDate = !string.IsNullOrEmpty(toFinalDate) ? Convert.ToDateTime(toFinalDate) : toDate
                };

                TransactionService.GetRejectedMerchantTransactionsResponse getRejectedMerchantTransactionResponse = transactionServiceClient.GetRejectedMerchantTransactions(getRejectedMerchantTransactionRequest);

                if (getRejectedMerchantTransactionResponse != null)
                {
                    sMessage = getRejectedMerchantTransactionResponse.Message;
                    bError = false;
                    bStatus = true;

                    lstMerchantTransactionModel = getRejectedMerchantTransactionResponse.lstRejectedMerchantTransactions.Select(T => new MerchantTransactionModel
                    {
                        TransactionID = T.TransactionID,
                        TransactionPNRNumber = T.TransactionPNRNumber,
                        MobileNumber = T.MobileNumber,
                        IsSecondaryTxn = T.IsSecondaryTxn,
                        SecTxnYesNo = T.IsSecondaryTxn ? "Yes" : "No",
                        PTTxnRefNo = T.PTTxnRefNo,
                        TxnDate = T.TxnDateTime.ToString("dd-MMM-yyyy"),
                        TxnTime = T.TxnDateTime.ToString("hh:mm tt"),
                        MerchantName = T.MerchantName,
                        PGTxnRefNo = T.PGTxnRefNo,
                        Amount = T.Amount,
                        TxnStatusID = T.TxnStatusID,
                        TxnStatus = lstTransactionStatusModel.Where(ts => ts.StatusID == T.TxnStatusID).Select(ts => ts.Status).FirstOrDefault(),
                        TransactionSettlementID = T.TxnSettlementID,
                        SettlementFailureCount = T.SettlementFailureCount == null ? "-" : T.SettlementFailureCount.ToString(),
                        TransactionPaymentID = T.TransactionPaymentID,
                        PaymentMode = T.PaymentModes,
                        ChannelType = T.ChannelTypes
                    }).ToList();
                }
                else
                {
                    sMessage = getRejectedMerchantTransactionResponse.Message;
                    bStatus = false;
                    bError = true;
                }
            }
            catch (Exception ex)
            {
                CreateLog.Error(this.GetType(), "An error occured in GetRejectedMerchantTransactions", ex);
                ViewBag.Error = true;
                ViewBag.Message = "An error occured. Please try again.";
            }
            return Json(new { aaData = lstMerchantTransactionModel, Message = sMessage, Status = bStatus, Error = bError }, JsonRequestBehavior.AllowGet);
        }

and .cshtml file'd code is as follow

merchantTransactionsTable = $('#merchantTransactionsTable').DataTable({
"processing": true,
"stateSave": true,
"columns": [
{ "data": "TransactionPNRNumber" },
{ "data": "MobileNumber" },
{ "data": "PaymentMode" },
{ "data": "ChannelType" },
{ "data": "SecTxnYesNo" },
{ "data": "TransactionPNRNumber" },
{ "data": "TxnDate" },
{ "data": "TxnTime" },
{ "data": "MerchantName" },
{ "data": "TransactionPaymentID" },
{ "data": "SettlementFailureCount" },
{ "data": "Amount" },
{ "data": "TxnStatus" },
],
"columnDefs": [

                {
                    "render": function (data, type, row) {
                        return '<input class="selectRow" name="selectRow" type="checkbox" TransactionPNRNumber="' + data + '" />';

                    },
                    "targets": 0,
                    "bSortable": false,
                },
                {
                    "render": function (data, type, row) {
                        return '<span class="label label-warning">' + data + '</span>';
                    },
                    "targets": 10
                },
                {
                    "render": function (data, type, row) {
                        return '<span class="fa fa-inr"></span>&nbsp;' + data;
                    },
                    "targets": 11
                }
            ]
        });

        $("#search").bind("click", function (e) {
            DismissStatusBox();
            $('#example-select-all').prop('checked', false);
            if ($('#MobileNumber').val() == "" && $('#FromDate').val() == "" && $('#ToDate').val() == "" && $('#ToTime').val() == "" &&
                 $('#TransactionStatus').val() == "") {
                alert('Please choose atleast one of the filter');
            }
            else if (($('#FromTime').val() != "" && $('#FromDate').val() == "") || ($('#ToTime').val() != "" && $('#ToDate').val() == "")) {
                alert("Plese select proper date time");
            }
            else {
                var MobileNumber = $('#MobileNumber').val() == "" ? 0 : $("#MobileNumber").val();
                var FromDate = $('#FromDate').val() == "" ? 0 : new Date($('#FromDate').val());
                var FromTime = $('#FromTime').val() == "" ? 0 : $('#FromTime').val();
                var ToDate = $('#ToDate').val() == "" ? 0 : new Date($('#ToDate').val());
                var ToTime = $('#ToTime').val() == "" ? 0 : $("#ToTime").val();

                $.ajax({
                    contentType: 'application/json; charset=utf-8',
                    dataType: 'json',
                    type: "POST",
                    url: '@Url.Content("~/Merchant/GetRejectedMerchantTransactions")',
                    data: JSON.stringify({ mobileNumber: MobileNumber, fromDate: convert(FromDate), toDate: convert(ToDate), fromTime: FromTime, toTime: ToTime }),
                    complete: function () {
                        $('#example-select-all').prop('checked', false);
                        merchantTransactionsTable.ajax.reload();
                    }
                });
            }
        });

```
I have tried all my best using json data validator and by manually checking json respponse data. but coudnot find any issue. Kindly help me to resolve this.

Thanks in advance!


Uncaught TypeError: Cannot set property '_DT_CellIndex' of undefined

$
0
0

Hello
I have a problem in one of my pages, where I get this error in the console_log.
"Uncaught TypeError: Cannot set property '_DT_CellIndex' of undefined"

I have other pages that display all the datatable options without problem. But this one.
All pages have the same include files (but for the specific js file).
This is a very simple page, with 2 tabs and small tables. I have been comparing the code line by line with a page where it works, and cannot find any difference.
Could somebody hint me where the problem might be so I can find it ? what gives this error in most cases ?
Thanks for the help
pat

error when filtering records on update or inserting new records

$
0
0

when i use "->where( $key = " in php file which returns the records to table, when i try to add or edit a record after updating or inserting the table doen't automatically reload and show the inserted or updated record.
the code of the php file:

<?php

/*
 * Editor server script for DB table Customers
 * Created by http://editor.datatables.net/generator
 */
$loggedid="";

if ( isset($_GET['loggedid']) ) $loggedid=$_GET['loggedid'];
//echo "hello " + $loggedid;
// DataTables PHP library and database connection
include( "lib/DataTables.php" );

// Alias Editor classes so they are easy to use
use
    DataTables\Editor,
    DataTables\Editor\Field,
    DataTables\Editor\Format,
    DataTables\Editor\Mjoin,
    DataTables\Editor\Options,
    DataTables\Editor\Upload,
    DataTables\Editor\Validate;

// The following statement can be removed after the first run (i.e. the database
// table has been created). It is a good idea to do this to help improve
// performance.
$db->sql( "CREATE TABLE IF NOT EXISTS `Customers` (
    `id` int(10) NOT NULL auto_increment,
    `custname` varchar(255),
    `custafm` varchar(9),
    `custusernameTax` varchar(255),
    `custpasswordTax` varchar(255),
    `custamka` varchar(255),
    `custusername` varchar(255),
    `custpassword` varchar(255),
    `loggedid` int(10) NOT NULL,
    PRIMARY KEY( `id` )
);" );

// Build our Editor instance and process the data coming from _POST
Editor::inst( $db, 'Customers', 'id' )
    ->fields(
        Field::inst( 'custname' ),
        Field::inst( 'custafm' ),
        Field::inst( 'custusernameTax' ),
        Field::inst( 'custpasswordTax' ),
        Field::inst( 'custamka' ),
        Field::inst( 'custusernameIKA' ),
        Field::inst( 'custpasswordIKA' ),
        Field::inst( 'loggedid' )
    )
    ->where( $key = "loggedid", $value =  $loggedid, $op = "=" )
    ->process( $_POST )
    ->json();

the code of the js file:

/*
 * Editor client script for DB table Customers
 * Created by http://editor.datatables.net/generator
 */
 var $loggedid;
 //$sendCodecust;

 $loggedid=loggedid;
 //alert("codecust: " + $loggedid);

(function($) {

    $(document).ready(function() {
        var editor = new $.fn.dataTable.Editor({
            ajax: 'php/table.Customers.php',
            table: '#Customers',
            fields: [{
                    "label": "Ονοματεπώνυμο:",
                    "name": "custname"
                },
                {
                    "label": "ΑΦΜ:",
                    "name": "custafm"
                },
                {
                    "label": "UserName Taxis:",
                    "name": "custusernameTax"
                },
                {
                    "label": "Password Taxis:",
                    "name": "custpasswordTax"
                },
                {
                    "label": "ΑΜΚΑ:",
                    "name": "custamka"
                },
                {
                    "label": "UserName IKA:",
                    "name": "custusernameIKA"
                },
                {
                    "label": "Password IKA:",
                    "name": "custpasswordIKA"
                },
                {
                    "label": "Logged Id:",
                    "name": "loggedid",
                    def: $loggedid
                }
            ]

        });

        //
        editor.on( 'onPreSubmit', function ( e, data ) {
            data.loggedid = loggedid;
        } );


        $('#Customers tfoot th').each(function() {
            var title = $(this).text();
            $(this).html('<input type="text" placeholder="Search ' + title + '" />');
        });


        //

        var table = $('#Customers').DataTable({
            ajax: 'php/table.Customers.php',
            "fnServerParams": function ( aoData ) {
                    aoData.push( { "name": "loggedid", "value": $loggedid } );
                    },
            columns: [{
                    "data": "custname"
                },
                {
                    "data": "custafm"
                },
                {
                    "data": "custusernameTax"
                },
                {
                    "data": "custpasswordTax"
                },
                {
                    "data": "custamka"
                },
                {
                    "data": "custusernameIKA"
                },
                {
                    "data": "custpasswordIKA"
                },
                {
                    "data": "loggedid"
                }
            ],
            select: true,
            lengthChange: false

        });

        new $.fn.dataTable.Buttons(table, [{
                extend: "create",
                editor: editor
            },
            {
                extend: "edit",
                editor: editor
            },
            {
                extend: "remove",
                editor: editor,
                formMessage: function(e, dt) {
                    var rows = dt.rows(e.modifier()).data().pluck('custname');
                    return 'do you want to delete the record(s) ' +
                        'with values? <ul><li>' + rows.join('</li><li>') + '</li></ul>';
                }
            }
        ]);

        table.buttons().container()
            .appendTo($('.col-sm-6:eq(0)', table.table().container()));
        // Apply the search
        table.columns().every(function() {
            var that = this;

            $('input', this.footer()).on('keyup change', function() {
                if (that.search() !== this.value) {
                    that
                        .search(this.value)
                        .draw();
                }
            });
        });
    });

}(jQuery));

Table does not update on "Create"

$
0
0

Edit works perfectly. Updates automatically. I can also see the JSON response for when editing. Create also works, problem is I have to refresh the page to see the new row that was added. Yes I am displaying a primary key row that is auto increment in the back end. I am not allow them to enter value for that. I hide the field when the create form comes up. What am I doing wrong for the page not be refreshing?

Thanks.

Multiple row insert based on multiple select inputs

$
0
0

I have an interesting scenario where I would like to perform one or more inserts simultaneously, depending on the number of options selected within two multiple select inputs (we'll call them Input A and Input B). I know the multiple option is available for the select field type, so I'm OK with setting up the Editor form. However, I do not want to insert an array of data (i.e., all of the selected options) into a single row. Rather, I want to create a new row for each selected option in Input A. I want Input B to have the same functionality. The result should be an insert of X rows , where X is the product of the number of options selected in Input A and Input B.

Example:

Input A selected options: 1, 2, 3
Input B selected options: a, b, c

3 selected options in Input A * 3 selected options in Input B should result in 9 newly inserted rows:

Row | Input A Destination Column | Input B Destination Column
-------------------------------------------------------------
 1  |  1                         |  a
 2  |  1                         |  b
 3  |  1                         |  c
 4  |  2                         |  a
 5  |  2                         |  b
 6  |  2                         |  c
 7  |  3                         |  a
 8  |  3                         |  b
 9  |  3                         |  c

Maybe there is a way to do this via rows.add(). Would this involve modifying the server side PHP script (I am using server-side processing)? I understand this functionality may not be part of the core DataTables code, but I was primarily looking for some direction on how to achieve something like this.

Thanks in advance!

Row grouping/ section rows in table

$
0
0

Hi!

I'm trying to add some structure to my DataTables-enabled table, and I'm looking to add some section labels/ dividers to my table.
What is the go-to method for doing this? I tried to search a bit but i can't seem to find the right method.

I'm looking to implement something like this (the "Product line" rows):
uxmatters.com/mt/archives/2009/09/images/figure4_tables.gif

Thanks!

Viewing all 82453 articles
Browse latest View live


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