Welcome Guest, Not a member yet? Register   Sign In
Ignited DataTables
#31

[eluser]cryogenix[/eluser]
thank you for your feedback. since you are using two_button as your sPaginationType, the NEXT and PREVIOUS buttons will actually be there. however if you are seeing it as text, then i'm suspecting you have some image directory issues because as far as i've tested, two_button mode should look like this (by default):

http://img257.imageshack.us/img257/2687/2but.png

while on the other hand, full_numbers mode should look like this:

http://img222.imageshack.us/img222/1690/fullnum.png

both of them render correctly in my tests so i think that there is nothing wrong with the code. do check your image directories (in the css: datatables.css) if they point to the previous and back buttons correctly.

cheers
hope it helps...
#32

[eluser]Dermis[/eluser]
thanks for your fast reply. im really appreciate it.
The path for the button image was correct.
When i check the css for generated table, the DIV for the two button was like this

Code:
<div class="dataTables_paginate fg-buttonset ui-buttonset fg-buttonset-multi ui-buttonset-multi paging_two_button" id="list_table_paginate">
<a class="fg-button ui-button ui-state-default ui-corner-left ui-state-disabled" title="Previous" id="list_table_previous"><span class="ui-icon ui-icon-circle-arrow-w"></span></a>
<a class="fg-button ui-button ui-state-default ui-corner-right" title="Next" id="list_table_next"><span class="ui-icon ui-icon-circle-arrow-e"></span></a></div>

while it should be the correct way like this

Code:
<div class="dataTables_paginate paging_two_button" id="list_table_paginate">
   <div class="paginate_disabled_previous" title="Previous" id="list_table_previous"></div>
   <div class="paginate_enabled_next" title="Next" id="list_table_next"></div>
</div>

right now i have no idea where should i change to make it display the correct class
#33

[eluser]cryogenix[/eluser]
are you using jquery-ui with your example? coz i admit, i've encountered some problems using jquery-ui so i decided to drop using it. aside from that, as i always suggest, try coding datatables first using a static dummy html file and make it work. once it works, it's easier transfering them to CI...
#34

[eluser]Dermis[/eluser]
thank cyrogenix for enlighten me up. Yup, its about conflict with jquery-ui

after i set bJQueryUI to false from your code sample, then the button apeared

Quote:'bJQueryUI' : false,

thanks a lot for your help
#35

[eluser]cryogenix[/eluser]
i'm very glad i've helped (oh wait i did? LOL)...
#36

[eluser]Dermis[/eluser]
LOL
#37

[eluser]Si Jampank[/eluser]
this is great.. I use it too. But can you help me for CRUD application?thanks
#38

[eluser]Si Jampank[/eluser]
i mean how can this library using for CRUD application?in that libraries i found how it can add addtional column for delete or update. But how can i use it?anyone help me.. so many thanks
#39

[eluser]saimaz[/eluser]
Hi everybody, its very good library for datatables (i'am a huge fan of datatables) but when i start using CI with Doctrine models relations with database i rewrite this library.

here it is :

Library :
Code:
&lt;?php

if (!defined("BASEPATH"))
    exit("No direct script access allowed");

/**
* Datatables(.net) for CodeIgniter
*
* This class/library is an attempt to port the native Datatables php script
* found at http://datatables.net/examples/data_sources/server_side.html for CodeIgniter
*
* @package    CodeIgniter
* @subpackage libraries
* @category   library
* @version    1.0
* @author     Vincent Bambico <[email protected]>
* @link       http://ellislab.com/forums/viewthread/160896/
*
* @upgrade for doctrine by Simonas Ć erlinskas [email protected]
*/
class Datatables {

    /**
     * CodeIgniter global variable
     *
     * @global object $ci
     * @name   $ci
     */
    protected $ci;

    /**
     * Copies an instance of CI
     */
    public function __construct() {
        $this->ci = & get_instance();
    }

    /**
     * Builds all the necessary query segments and performs the main query based on passed arguments
     *
     * @param string $model
     * @param string $columns
     * @param string $index
     * @return string
     */
    public function generate($model, $columns, $index) {


        /*
         *   WHERE clause
         */
        $sWhere = "";

        if ($this->ci->input->post("sSearch") != "") {
            $sWhere = "";

            for ($i = 0; $i < count($columns); $i++)
                $sWhere .= $columns[$i] . " LIKE '%" . $this->ci->input->post("sSearch") . "%' OR ";

            $sWhere = substr_replace($sWhere, "", -3);
        }
        if ($sWhere == "") {
            $sWhere = '1';
        }
        /*
         *   ORDER clause
         */
        $sOrder = "";

        if ($this->ci->input->post("iSortCol_0") != null) {
            $sOrder = "";

            for ($i = 0; $i < intval($this->ci->input->post("iSortingCols")); $i++)
                $sOrder .= $columns[intval($this->ci->input->post("iSortCol_" . $i))] . " " . $this->ci->input->post("sSortDir_" . $i) . ", ";

            $sOrder = substr_replace($sOrder, "", -2);
        }

        if ($sOrder == "") {
            $sOrder = $columns[1];
        }

        /*
         *   LIMIT clause
         */

        $sLimit = "LIMIT ";

        if ($this->ci->input->post("iDisplayStart") && $this->ci->input->post("iDisplayLength") != "-1")
            $sLimit .= $this->ci->input->post("iDisplayStart") . ", " . $this->ci->input->post("iDisplayLength");
        else {
            $iDisplayLength = $this->ci->input->post("iDisplayLength");

            if (empty($iDisplayLength))
                $sLimit .= "0,10";
            else
                $sLimit .= "0," . $iDisplayLength;
        }

        $select = implode(", ", $columns);

        $q = Doctrine_Query::create()
                        ->select($select)
                        ->from($model)
                        ->where($sWhere)

                        /*  in order clause is joined the limit clause, because i did not find how to range result in doctrine  */
                        ->orderBy($sOrder . " " . $sLimit)
                        ->setHydrationMode(Doctrine::HYDRATE_ARRAY);
        $rResult = $q->execute();

        /*
         *  Count all records without ordering and pagination.
         *
         *   if someone knows how to get correct num rows at that query before of all records let me know [email protected]
         */

        $q_all = Doctrine_Query::create()
                        ->select('COUNT(id) AS num_rows')
                        ->from($model)
                        ->where($sWhere)
                        ->setHydrationMode(Doctrine::HYDRATE_ARRAY);

        $rResult_all = $q_all->execute();

        $num_all = $rResult_all[0]['num_rows'];

        $aaData = array();

        $row = 0;
        foreach ($rResult as $r) {
            for ($i = 0; $i < count($columns); $i++) {
                $aaData[$row][$i] = $r[$columns[$i]];
            }
            $row++;
        }

        $sOutput = array
            (
            "sEcho" => intval($this->ci->input->post("sEcho")),
            "iTotalRecords" => "$num_all",
            "iTotalDisplayRecords" => "$num_all",
            "aaData" => $aaData
        );

        return json_encode($sOutput);
    }

}

in controler you need to define MODEL name not table!

Hope it helps, works very well, and for me its very useful.
#40

[eluser]Unknown[/eluser]
Hi saimaz,

can u provide your model example for this library?

many thanks! Smile




Theme © iAndrew 2016 - Forum software by © MyBB