Lasal Sethiya
Lasal Sethiya

Reputation: 201

Kendo grid conditions

dataSource: {
                    pageSize: 5,
                    serverPaging: false,
                    serverSorting: false,
                    schema: {
                        model: {
                            id: "EmploymentHistoryId",
                            fields: {
                                EmployerName: { validation: { required: true } },
                                JobTitle: { validation: { required: true } },
                                PrimaryPlaceOfPractice: { validation: { required: true } },
                                StartDate: { validation: { required: true } },
                                EndDate: { validation: { required: true } },
                            }                                                                                                                                                                  
                        }
                    }
                },
                sortable: true,
                pageable: true,
                toolbar: ["create"],
                editable: "popup",
                autoSync: true,
                columns: [
                    {
                        field: "EmployerName",
                        title: "Name of Employer"
                    },{
                        field: "JobTitle",
                        title: "Job Title"
                    },{
                        field: "PrimaryPlaceOfPractice",
                        title: "Primary Place Of Practice"
                    },
                     {
                        field: "StartDate",
                        title: "Start Date",
                        template: "#= kendo.toString(kendo.parseDate(StartDate, 'yyyy-MM-dd'), 'MM/dd/yyyy') #"

                    }, {
                        field: "EndDate",
                        title: "End Date",
                        template: "#= kendo.toString(kendo.parseDate(EndDate, 'yyyy-MM-dd'), 'MM/dd/yyyy') #"

                    },{
                        command: ["destroy", "edit"],
                        title: "Action"
                    }
                ]

here by "PrimaryPlaceOfPractice" db return 1 or 0. But what I want to do is I want to show "Yes" in Grid if it returns 1 and "No" if 0. How can I do this. Is there a way to handle conditions. Is there a way to show a different value instead of a retrieved value from database.

Upvotes: 1

Views: 90

Answers (1)

Pluc
Pluc

Reputation: 2929

/* ... */
columns: [
/* ... */
},{
    field: "PrimaryPlaceOfPractice",
    title: "Primary Place Of Practice",
    template: "#=PrimaryPlaceOfPractice == 1 ? 'Yes' : 'No'#"
},{
/* ... */
]
/* ... */

Upvotes: 2

Related Questions