This is a migrated thread and some comments may be shown as answers.
Mobile switch control not displaying Grid Cell MVC
2 Answers 19 Views
This is a migrated thread and some comments may be shown as answers.
Mohammed
Top achievements
Rank 1
Veteran
Mohammed asked on 02 May 2020, 04:46 PM

Hi,

 

I want to display Mobile switch control in Grid MVC . when i tried only checkbox displaying.

 

Please help

2 Answers, 1 is accepted

Sort by
0
Nikolay
Telerik team
answered on 05 May 2020, 02:50 PM

Hello Mohammed,

The Kendo MobileSwitch can be implemented as a column editor to a boolean model field. Here a ClientTemplate can be used supplying an input of type checkbox. Later in the DataBound event handler, the Switch will be initialized. 

columns.Bound(p => p.Discontinued).ClientTemplate("<input class='customClass' #if (Discontinued) { # checked='checked' # } # type='checkbox' />").Editable("notEditable");

function notEditable(e){
        return false;
    }

.Events(ev => ev.DataBound("onDataBound"))
 
function onDataBound(e) {
    this.tbody.find(".customClass").kendoMobileSwitch({
        change: function (e) {
            var grid = $("#grid").getKendoGrid();
            var dataItem = grid.dataItem(this.element.closest("tr"));
            dataItem.set("Discontinued", e.checked);
        }
    });
}

For your convenience, I am attaching a small project demonstrating the above. Let me know if you have any questions.

Regards,
Nikolay
Progress Telerik

Progress is here for your business, like always. Read more about the measures we are taking to ensure business continuity and help fight the COVID-19 pandemic.
Our thoughts here at Progress are with those affected by the outbreak.
0
Mohammed
Top achievements
Rank 1
Veteran
answered on 06 May 2020, 05:57 PM
Thank you Nikolay Thant solved my problem!! :)
Tags
Grid
Asked by
Mohammed
Top achievements
Rank 1
Veteran
Answers by
Nikolay
Telerik team
Mohammed
Top achievements
Rank 1
Veteran
Share this question
or