Filter on calculated column doesn't work

4 posts, 0 answers
  1. Ro
    Ro avatar
    2 posts
    Member since:
    Sep 2018

    Posted 17 Sep 2018 Link to this post

    Hi there! i'm giving support to a client who has a app developed on cakephp, and for grid they used Kendo ui. I have a table on database with the columns 'periodo', 'nro_beneficio', 'nombre', 'cuil', 'monto_haber' and 'estado'. And the fields 'porcentaje' and 'monto_anterior' are calculated fields. On the grid all fields shows ok, but the filter of the columns "porcentaje" and "monto_anterior" doesn't work. Can you tell me what i'm doing wrong??

    $(document).ready(function() {


       var dataSource = new kendo.data.DataSource({
            type: 'json',
            transport: {
                read: {
                    url: BASE_URL + '<?php echo $this->Html->url( array("controller" => "reportes", "action" => "haberes.json") ); ?>',
                    dataType: 'json'
                },
            },
            filter: {field:'Haberespilotoscabecera.periodo', operator:'eq', value:'<?php if(isset($date)) echo $date; ?>'},
            schema: {
                model: {
                    id: 'haber_piloto_detalle_id',

                    fields: {
                        periodo: {
                            from: 'Haberespilotoscabecera.periodo',
                            type: 'date'
                        },
                        nro_beneficio: {
                            from: 'Haberespiloto.nro_beneficio',
                            editable: false
                        },                      
                        nombre: {
                            from: 'Piloto.nombre',
                            editable: false
                        },
                        cuil: {
                            from: 'Piloto.cuil',
                            editable: false                 
                        },
                        monto_haber: {
                            from: 'Haberespiloto.monto_haber',
                            editable: false                 
                        },
                        estado: {
                            from: 'Haberespiloto.estado_importacion_haber_id',
                            editable: false         
                        },
                    }
                },
                data: 'results',
                total: 'total'
            },
            batch: true,
            serverPaging: true,
            serverSorting: true,
            serverFiltering: true,
            pageSize: 30
        });



        var wnd,detailsTemplate;

        var columns = [
        {
            field: 'Haberespiloto.nro_beneficio',
            title: '<?php echo __("Nro Beneficio"); ?>'
        },{
            field: 'Haberespiloto.numero_legajo',
            title: '<?php echo __("Legajo"); ?>',
            filterable: true
        },{
            field: 'Piloto.name',
            title: '<?php echo __("Nombre"); ?>'

        },{
            field: 'Estadosimportacionhaberespiloto.nombre',
            title: '<?php echo __("Estado"); ?>',
            
        },{
            field: 'Haberespiloto.monto_haber',
            title: '<?php echo __("Monto"); ?>',
            template: '#= kendo.toString(kendo.parseFloat(Haberespiloto.monto_haber), "c") #',
            format: '{0:c}'

        },{
            field: 'monto_anterior',
            title: '<?php echo __("Monto Ant."); ?>',
            template: '#= kendo.toString(kendo.parseFloat(Haberespiloto.monto_anterior), "c") #',
            format: '{0:c}'

        },{
            field: 'porcentaje',
            title: '<?php echo __("Porcentaje"); ?>',
            template: '#= kendo.toString(kendo.parseFloat(Haberespiloto.porcentaje), "p") #',
            format: '{0:p}',
            filterable:

        }];

     
    });

  2. Preslav
    Admin
    Preslav avatar
    590 posts

    Posted 19 Sep 2018 Link to this post

    Hi Ro,

    Based on the provided description, I believe you should add the "porcentaje" and "monto_anterior" to the "schema.model.fields" with the from property of "Haberespiloto.porcentaje" and "Haberespiloto.monto_anterior" (similar to the other fields). Also, set the type to "number".
    I hope this helps.


    Regards,
    Preslav
    Progress Telerik
    Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
  3. Ro
    Ro avatar
    2 posts
    Member since:
    Sep 2018

    Posted 20 Sep 2018 in reply to Preslav Link to this post

    Hi!!, thank you so much for your quickly answer!!.
    I added those fields to the shema model fields but it's still doesn't work.
    Also it shows me this error: SQLSTATE [42522] unknown column Haberespiloto.porcentaje

  4. Preslav
    Admin
    Preslav avatar
    590 posts

    Posted 24 Sep 2018 Link to this post

    Hello Ro,

    I checked the provided information again, and unfortunately, I was not able to understand the cause of the described problem.

    Having said that, could you please provide an isolated runnable page that clearly replicates and isolates the issue? This will help me better understand the case, and I will be able to provide assistance to the best of my knowledge.


    Regards,
    Preslav
    Progress Telerik
    Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
Back to Top