checkMark function on string attribute


#1

I’m not able to show up a check mark in a kendo grid - I think the issue here is that the field is a string.
I do not want to change the original format of the attribute in the type since used in other back end procedures.
Any insight about how can I solve this issue?

I have the following definition

                    "id": "c3generated",
                    "label": "{~RevenueProtection.Detail.DetailTabs.DetailsLocation.InspectionsList.columns.C3Generated.label~}",
                    "field": "revenueOpportunity[0].c3Generated",
                    "format": {
                        "funk": "checkMark",
                        "args": [
                            ["true"]
                        ]
                    }
                }

of course in the datasource I have included revenueOpportunity.c3Generated


#2

Is c3Generated a boolean or a string?

If it is a string, then your configuration should work as is.
However, if it is a boolean, then in your configuration you should change "true" (string) to true (boolean).


#3

c3generated is declared as string in the RevenueOpportunity so there is something wrong since the check mark does not show up - I did see in network tab 2 fetches generated at the same time by the data source used by the kendo grid and one of these 2 calls is marked as cancelled ( the second call instead has the right response populated) - I do not know if this has somehow an impact on this issue


#4

@matt as mentioned above the filed is declared as string but stil does not show up … then into the helper function for this customer I’ve found the below function …

    /**
     * If the input value if true, return the check mark.
     * @param  {any value} value [any value that can be verified]
     * @param  {[value]} trueValue [a value that will make the function return check mark if the 'value' parameter
     *                                 is equal to the trueValue]
     */
    customerCheckMark: function(value, trueValues) {
        if (_.contains(trueValues, value)) {
            return "<i class='icon-ok'></i>";
        }
    }

And then also changing the configuration to use this helper function the checkMark does not show up

                {
                    "id": "c3generated",
                    "label": "{~RevenueProtection.Detail.DetailTabs.DetailsLocation.InspectionsList.columns.C3Generated.label~}",
                    "field": "revenueOpportunity.c3Generated",
                    "format": {
                        "funk": "customerCheckMark",
                        "args": [
                            "revenueOpportunity.c3Generated",
                            "true"
                        ]
                    }
                }

#5

format.args is already an array, so if you want to pass an array as an argument, you will need to do this:

"format": {
    "funk": "customerCheckMark",
    "args": [
        [
            "revenueOpportunity.c3Generated",
            "true"
        ]
    ]
}

I suspect that somehow the value is not being passed to the helper function correctly. Can you try to set a breakpoint in your helper function?


#6

I did include a console.log to show up the variables passed - after that I had to change the helper function like this

    customerCheckMark: function(value, trueValues) {
        if( value == trueValues ) {
        return "<i class='icon-ok'></i>";
        }
    }

and the parameters are passed like this

                {
                    "id": "c3generated",
                    "label": "{~RevenueProtection.Detail.DetailTabs.DetailsLocation.InspectionsList.columns.C3Generated.label~}",
                    "field": "revenueOpportunity.c3Generated",
                    "format": {
                        "funk": "enelCheckMark",
                        "args": [
                            "true","revenueOpportunity[0].c3Generated"
                        ]
                    }
                }

closed #7