Code Monkey home page Code Monkey logo

Comments (16)

widnyana avatar widnyana commented on June 2, 2024

what kind of data you'd pass as a parameter to is_comm() ?

from ignited-datatables.

n1crack avatar n1crack commented on June 2, 2024

Try

->edit_column('fee_is_comm', '$1', 'is_comm(fee_is_comm)')

On Sat, Apr 19, 2014 at 8:47 AM, anupalusoft [email protected]
wrote:

helper function i created:
function is_comm($check)
{
if($check)
return 'Yes';
else
return 'No';
}
Now with ignited table i code in controller:
$this->datatables
->select('fee_id, fee_name, fee_is_comm, fee_remarks')
->unset_column('fee_id')
->edit_column('fee_is_comm', is_comm('$1'), 'fee_is_comm')
->add_column('Actions', get_ajax_buttons('$1'), 'fee_id')
->from('fee_types');
The the helper function treating the $check as string ('$1') which is actually Boolean (0|1) from database. It always return "Yes".

See the issue if we can fix it.

Reply to this email directly or view it on GitHub:
#50

from ignited-datatables.

anupalhub avatar anupalhub commented on June 2, 2024

@n1crack Its not working. It return 'Yes' always.
Actually what ever we pass in function parameter it always treat as string '$1' in if condition of that function. thus always return 'Yes' in helper function.
@widnyana It is actually a Boolean value which i am trying to pass but seems like it treating it '$1' always.

from ignited-datatables.

widnyana avatar widnyana commented on June 2, 2024

try this

function is_comm($check)
{
    if(is_bool($check) ) {
        if($check === true)
            return 'Yes';
        else
            return 'No';
    }
    else {
        return 'not boolean';
    }
}

i just wondering, what will returned with that func :/

from ignited-datatables.

anupalhub avatar anupalhub commented on June 2, 2024

It prints "not boolean" :/
But from database it comes boolean value then how it treating it as non boolean ?!

from ignited-datatables.

widnyana avatar widnyana commented on June 2, 2024

try to validate with another method, maybe comparing with string could help 😆

from ignited-datatables.

anupalhub avatar anupalhub commented on June 2, 2024

I don't know what to do. I tried all methods. Its an issue in library. Please give a fix. I can explain if you don't understand.

from ignited-datatables.

fjafferi avatar fjafferi commented on June 2, 2024

I can confirm this is an issue. I am using 1.15 version.

from ignited-datatables.

anupalhub avatar anupalhub commented on June 2, 2024

@fjafferi yes this is the big issue and now this plugin is useless for me. :(
Hoping developers will find any fix for this.

from ignited-datatables.

n1crack avatar n1crack commented on June 2, 2024

I will look for it as soon as i have free time.

On Tue, May 27, 2014 at 11:27 AM, anupalusoft [email protected]
wrote:

@fjafferi yes this is the big issue and now this plugin is useless for me. :(

Hoping developers will find any fix for this.

Reply to this email directly or view it on GitHub:
#50 (comment)

from ignited-datatables.

fjafferi avatar fjafferi commented on June 2, 2024

thanks @n1crack. I am looking into it myself. I'll update this post if i figure out the problem.

Thanks again.

from ignited-datatables.

zadro avatar zadro commented on June 2, 2024

double quotes on the function

->edit_column('fee_is_comm', '$1', "is_comm('fee_is_comm')")

from ignited-datatables.

victor-rincon avatar victor-rincon commented on June 2, 2024

regards,

I have the following code

Call Back

function crearBotonAccion($ID=0,$modulo='',$titulo='',$accion='')
    {   
         $CI =& get_instance();
         $CI->load->library('session');
        $arrayKey= array();
        $data = array();
        foreach ($CI->session->userdata('SubModulos') as $value) {
                $arrayKey =  array(
                    'agregar' => $value->agregar,
                    'ver' => $value->ver,
                    'editar' => $value->editar,
                    'eliminar' => $value->eliminar,
             );
                $data = array(
                    'urlAgregar' =>base_url().strtolower($titulo).'/'.$accion,
                    'url' => base_url().strtolower($titulo).'/'.$accion.'/'.$ID,
                    'titulo' => strtolower($titulo),
                    'accion' => $accion,
                    'id' => $titulo."_".$accion,
                 );
            if($value->nombre == $modulo && $arrayKey[$accion] =='si')
            {

                return $CI->load->view("botones/".$accion, $data);

            }       
        }
    }

View

<a data-rel="tooltip" title="Editar <?php $titulo;?>" href="<?php echo $url;?>" class="green" id="<?php $id;?>">
 <i class="icon-edit bigger-150"></i>
</a>

Model

->add_column('action', '$1', 'crearBotonAccion(usuarioId, "Usuario", usuario, "editar")');

When I print to console me separate the html view of the json format and gives me an error in the datatable, but return a string I get well

Error if I use

return $CI->load->view("botones/".$accion, $data);

Successful if I use

return "<a title='".$accion.' '.strtolower($titulo)."'href='".$url2."'class='".$class."' id='".$titulo.'_'.$accion."'>
                            <i class='".$icon." bigger-120'></i> Crear ". $titulo ."</a>";

Sorry for my english

from ignited-datatables.

kotakkreatif avatar kotakkreatif commented on June 2, 2024

@anupalhub in my case, I can make this works, your function changed to this
function is_comm($check) { if(intval($check) == 1) return 'Yes'; else return 'No'; }

and in the controller
->edit_column('fee_is_comm', '$1', 'is_comm("fee_is_comm")')

maybe this works too
->edit_column('fee_is_comm', '$1', "is_comm('fee_is_comm')")

from ignited-datatables.

dev-alham avatar dev-alham commented on June 2, 2024

$this->is_comm('fee_is_comm')

from ignited-datatables.

n1crack avatar n1crack commented on June 2, 2024

First of all you can't address the function as it is now directly. you have to put it in quotes. In addition that the function has to be global. That means you have to define your function as a helper function.

My first comment was working. Again put the function in quotes.
->edit_column('fee_is_comm', '$1', 'is_comm(fee_is_comm)')

it returned always true in the first function, because you were checking if it has a value.
@widnyana was right, it is not a boolean. it is a string.
probably if($check == 'true' ) or if($check == 1 ) would worked.

I could have improved this library but I don't want anyone break their codes. I have rewritten the codes and make 'Composer' compatible a while ago. You can find the library here: datatables

The cons is you can't use active records like IgnitedDatatables, you have to write your sql query. And you have to use Composer of course.

the solution that I found is using a callback function instead of passing a string : edit column example. I think this is the best practice and it is as simple as the code below.

->edit('fee_is_comm',  function($data) {
  return $this->is_comm( $data['fee_is_comm'] );
})

And it's been 4 years. it is still an active issue. wow 😮

from ignited-datatables.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.