Search code examples
extjsextjs4extjs4.2

Rendering conditional statement on grid templatecolumn [ExtJS 4.2.1]


I have been successfully rendering conditional statement on normal grid column

{
        header: '&nbsp',
        dataIndex: 'status_b2',
        menuDisabled: true,
        flex: 1,
        sortable: false,
        renderer : function(value, meta) {
            var status = value.split("<br/>")[0];

            if (status == "Unset Price"){
                meta.style = "background-color:pink;";
            }
            else if (status == "Available"){
                meta.style = "background-color:green;";
            }else if (status == "Booked Unpaid"){
                meta.style = "background-color:yellow;";
            }else if (status == "Booked Paid"){
                meta.style = "background-color:orange;";
            }else if (status == "Checked In"){
                meta.style = "background-color:red;";
            }else if (status == "Checked Out"){
                meta.style = "background-color:purple;";
            }
            return value;
}

My question is how to render with conditional logic on templatecolumn grid? If the room_status == "Dirty", I want to add background-color as red.

{
            text: 'Room List',
            xtype: 'templatecolumn',
            tpl: 'ROOM {room_number} <br/> {room_type_name} <br/> {bed_type} | {room_status}',
            menuDisabled: true,
            flex: 1,
            sortable: false
 }

Solution

  • follow these links sencha forum and stackoverflow link

    We can have some inline functions and call them. Follow this link. Implement your logic inside these functions.