ExpressionEngine CMS
Open, Free, Amazing

Thread

This is an archived forum and the content is probably no longer relevant, but is provided here for posterity.

The active forums are here.

Ignited DataTables

July 15, 2010 2:51am

Subscribe [119]
  • #451 / Oct 06, 2014 10:48pm

    pansengtat

    1 posts

    Hi,

    I am pretty new to the Ignited Datatables wrapper for Datatables (and new to this site). I have been using standard Datatables and Editor for close to half-a-year already but using Ignited Datatables is something I feel the need to use because of the way it can handle JOINs and Aggregate Functions that standard Datatables cannot perform. My question is, if it is possible to combine use of Ignited Datatables (the native PHP version at: https://github.com/n1crack/IgnitedDatatables-php-library) with Editor. I understand that this is a wrapper for Datatables, but if I wish to create an instance of Editor on Ignited Datatables, how do I initialize?

    This is the code I used for creating an instance of a Datatable using Ignited Datatables:

    ajax.php

    require_once('IgnitedDatatables.php');
    $datatables = new Datatables('mysqli');
    
    $datatables
    ->select('DATE_FORMAT(TestRequestMain.TestRequestDateTime, "%Y-%m-%d") as trDate')
    ->select('ProjectMain.Name as prjName')
    ->select('POnumberMain.POnumber as poNum')
    ->select('AssignedGroup.Name as grpName')
    ->select('ProfitCenterMirror.Name as profitCenter')
    ->select('RegionMirror.Name as regName')
    ->select('TestRequestMain.TestTitle as trTitle')
    ->select('POnumberMain.TotalMandayReq as TotalMandayReq, POnumberMain.TotalMandayReq * POnumberMain.CostRate as totalCostAppr')
    ->select('(SUM(Schedule.ManHrsNM) + SUM(Schedule.ManHrsOT) + SUM(Schedule.ManHrsOTSunPH))/8 as totalMandayUsed, (SUM(Schedule.ManHrsNM) + SUM(Schedule.ManHrsOT) + SUM(Schedule.ManHrsOTSunPH))/8 * POnumberMain.CostRate as totalCostPaid, (POnumberMain.TotalMandayReq * POnumberMain.CostRate) - ((SUM(Schedule.ManHrsNM) + SUM(Schedule.ManHrsOT) + SUM(Schedule.ManHrsOTSunPH))/8 * POnumberMain.CostRate) as totalCostBalance')
    ->select('POnumberMain.QuoteNum as quoNum')
    ->select('POStatusMirror.String as poStatus')
    ->select('POnumberMain.DateStart as DateStart, POnumberMain.DateEnd as DateEnd, POnumberMain.DateClosed as DateClosed, POnumberMain.Remarks as Remarks,POnumberMain.CostRate as CostRate,POnumberMain.ProjectID as prjID')
    ->from('POnumberMain')
    ->join('ProjectMain', 'POnumberMain.ProjectID = ProjectMain.ID', 'left')
    ->join('TestRequestMain', 'POnumberMain.POnumber = TestRequestMain.POpoNumber', 'left')
    ->join('Schedule', 'TestRequestMain.TestRequestNo = Schedule.TestRequestNo', 'left')
    ->join('AssignedGroup', 'POnumberMain.OutsourceGroupID = AssignedGroup.ID', 'left')
    ->join('ProfitCenterMirror', 'POnumberMain.ProfitCenterID = ProfitCenterMirror.ID', 'left')
    ->join('RegionMirror', 'POnumberMain.RegionID = RegionMirror.ID', 'left')
    ->join('POStatusMirror', 'POnumberMain.POStatusID = POStatusMirror.ID', 'left');
    
    echo $datatables->generate();

    main_page.php

    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
    <html>
    <head>
    <meta http-equiv="content-type" content="text/html; charset=utf-8" />
    <link rel="shortcut icon" type="image/ico" href="http://www.datatables.net/media/images/favicon.ico" />
    <title>Ignited DataTables example</title>
    
    <link rel="stylesheet" type="text/css" href="css/jquery.dataTables.css">
    
    [removed][removed]
    [removed][removed]
    [removed]
    $(document).ready(function()
      {
        $('#example').dataTable
        ({
          'bServerSide'    : true,
          'sAjaxSource'    : 'ajax.php'
        });
      });
    [removed]
    </head>
    <body id="dt_example">
    <div id="container">
    <h1>Ignited Datatables - Testing</h1>
      <table border="0" cellpadding="4" cellspacing="0" class="display" id="example">
        <thead>
          <tr>
            <th>Request Date</th>
      <th>Project Name</th>
      <th>Razer PO Number</th>
      <th>Outsource Test Hse</th>
      <th>Profit Center</th>
      <th>Region</th>
      <th>Test Request Title</th>
      <th>Total Manday Req.</th>
      <th>Total Approved Cost</th>
      <th>Used Manday</th>
      <th>Total Paid Cost</th>
      <th>Total Balance Cost</th>
      <th>Invoice Number</th>
      <th>PO Status</th>
      <th>Date Start</th>
      <th>Date End</th>
      <th>Date Closed</th>
      <th>Remarks</th>
      <th>Outsource Cost Per Manday</th>
      <th>Project ID (Hidden)</th>
          </tr>
        </thead>
        <tbody>
          <tr>
            <td>loading…</td>
          </tr>
        </tbody>
      </table>
    </div>
    </body>
    </html>
  • #452 / Oct 08, 2014 8:08am

    ticovisky

    1 posts

    Hello guys!!

    3 days were passed and I could not solve my problem with the this awesome library.

    I have a view with the table that will be load by a method. The JSON is ok, it’s valid and if I check the firebug I can see the data changing if I search for a data.

    Well, let me past the code.

    VIEW:

    <table id="tabela_estados" border="1" cellpadding="2" cellspacing="1" class="table table-striped table-bordered table-hover">
         <thead>
            <th>A</th>
            <th>B</th>     
            <th>C</th>
         </thead>
    <table>
                [removed]
                         $(document).ready(function ()
                         {
                              var oTable = $("#tabela_estados").DataTable({
                                   "bProcessing": true,
                                   "bServerSide": true,
                                   "sServerMethod": "POST",
                                   "sAjaxSource": "/inicio/carrega_estados",
                                   "bJQueryUI": true,
                                   "bDeferRender": true,
                                   "sPaginationType": "full_numbers",
                                   "iDisplayStart ": 10,
                                   "aoColumns": [
                                        {"sName": "id"},
                                        {"sName": "nome"},
                                        {"sName": "uf"}
                                   ],
                                   "oLanguage": {
                                        "sProcessing": ""
                                   },
                                   "fnServerData": function (sSource, aoData, fnCallback) {
                                        $.ajax
                                                  ({
                                                       "dataType": "JSON",
                                                       "type": "POST",
                                                       "url": sSource,
                                                       "data": aoData,
                                                       "success": fnCallback
                                                  });
                                   }
                              });
                         });
                [removed]

    Controller

    function carrega_estados()
    {
            $this->datatables
                    ->select("id, nome, uf")
                    ->from("estado");
            $data["json_response"] = $this->datatables->generate();
            $this->load->view("includes/v_response", $data);
    }

    VIEW: v_response

    <?php
    echo json_response;

    This is my JSON:

    
    {"draw":0,"iTotalRecords":27,"iTotalDisplayRecords":27,"data":[["1","Acre","AC"],["2","Alagoas","AL"],["3","Amazonas","AM"],["4","Amapá","AP"],["5","Bahia","BA"],["6","Ceará","CE"],["7","Distrito Federal","DF"],["8","Espírito Santo","ES"],["9","Goiás","GO"],["10","Maranhão","MA"],["11","Minas Gerais","MG"],["12","Mato Grosso do Sul","MS"],["13","Mato Grosso","MT"],["14","Pará","PA"],["15","Paraíba","PB"],["16","Pernambuco","PE"],["17","Piauí","PI"],["18","Paraná","PR"],["19","Rio de Janeiro","RJ"],["20","Rio Grande do Norte","RN"],["21","Rondônia","RO"],["22","Roraima","RR"],["23","Rio Grande do Sul","RS"],["24","Santa Catarina","SC"],["25","Sergipe","SE"],["26","São Paulo","SP"],["27","Tocantins","TO"]],"sColumns":"id,nome,uf"}

    If I set bServerSide = FALSE on the JS it only show “Loading…” (http://prntscr.com/4u64gn)

    Informations:
    Library version: 2.0
    Jquery: 1.11
    Datatable JS: 1.10.2

    I don’t know what to do, could anyone help me?

     

.(JavaScript must be enabled to view this email address)

ExpressionEngine News!

#eecms, #events, #releases