Quantcast
Channel: Telerik Forums RSS
Viewing all articles
Browse latest Browse all 94857

Lose row Css style after close Popup Edit windows ?

$
0
0

Hi

i have add an grid and set some styles to it like row color from databound event and command button styles and it works fine, but when i cancel popup edit i found that row loss the style of if and when i try to fire edit event throw js i got err:

Uncaught TypeError: Cannot read property 'find' of undefined

my js code is:

@section scripts{
    <scripttype="text/javascript">
        function getAdditionalData() {
            return {
                Clinic_Code_ID: $('#Clinic_Code_ID').val(),
                Doctor_ID: $('#Doctor_ID').val(),
                Visit_Date: $('#Visit_Date').val(),
            };
        }
 
        $(document).ready(function () {
            $('#showGrid').click(function () {
                if ((!$('#Clinic_Code_ID').val()) && (!$('#Doctor_ID').val()) && (!$('#Visit_Date').val())) {
                    $("#SHPTData").data("kendoGrid").dataSource.data([]);
                    alert("من فضلك ادخل القيمة المراد البحث عنها");
                    return;
                }
                else {
                    $('#SHPTData').data('kendoGrid').dataSource.fetch();
                }
            });
        });
 
        function dataBound() {
            var grid = this;
            grid.tbody.find("tr[role='row']").each(function () {
                var model = grid.dataItem(this);
                if (model.Clinic_Code_ID == 1) {
                    $(this).css("color", "blue");
                }
                else {
                    $(this).css("color", "green");
                }
                $(".btn-success").removeClass("k-button");
                $(".btn-danger").removeClass("k-button");
            });
        }
 
        function onEdit(e) {
            //Triggered when the window is closed (always)
            e.container.data("kendoWindow").bind("deactivate", function () {
 
                dataBound();
            })
        }
 
        function error_handler(e) {
            if (e.errors) {
                var message = "Errors:\n";
                $.each(e.errors, function (key, value) {
                    if ('errors' in value) {
                        $.each(value.errors, function () {
                            message += this + "\n";
                        });
                    }
                });
                alert(message);
            }
        }
    </script>
}
 

i try on function onEdit replace dataBound() with:

$(".my_Editbtn").removeClass("k-button");
$(".my_Delbtn").removeClass("k-button");

Full Grid Code:

    @(Html.Kendo().Grid<MhafezClinic.Models.DBContext.VisitData>()
            .Name("SHPTData")
            .HtmlAttributes(new { style = "font-weight:bold; vertical-align:middle; font-size:medium;" })
            .AutoBind(false)
            .Columns(columns =>
{
    columns.Bound(e => e.ClinicCode)
        .ClientTemplate("#=ClinicCode.Clinic_Code_Name#")
        .Sortable(false).HtmlAttributes(new { @style = "text-align:center;" })
        .HeaderHtmlAttributes(new { @style = "font-weight:bold; text-align:center;" })
        .Filterable(false).Title("العيادة").Width(65);
 
    columns.Bound(e => e.PT_Clinic_ID)
        .HtmlAttributes(new { @style = "text-align:center;" })
        .HeaderHtmlAttributes(new { @style = "font-weight:bold; text-align:center;" })
        .Title("رقم الملف الطبى").Width(130);
 
    columns.Bound(e => e.PT_Name)
        .HeaderHtmlAttributes(new { @style = "font-weight:bold; text-align:center;" })
        .Title("إسم المريض").Width(200);
 
    columns.Bound(e => e.Nots)
        .HeaderHtmlAttributes(new { @style = "font-weight:bold; text-align:center;" }).Filterable(false)
        .Sortable(false).Title("ملاحظات").Width(180);
 
    columns.Bound(e => e.PT_Phone_No)
        .HtmlAttributes(new { @style = "text-align:center;" })
        .HeaderHtmlAttributes(new { @style = "font-weight:bold; text-align:center;" })
        .Filterable(false).Sortable(false).Title("رقم التليفون").Width(130);
    //columns.Bound(e => e.Visit_Date)
    //    .HtmlAttributes(new { @style = "text-align:center;" })
    //    .HeaderHtmlAttributes(new { @style = "font-weight:bold; text-align:center;" }).Width(105)
    //    .Filterable(false).Sortable(false);
    columns.Bound(e => e.VisitTime)
        .HtmlAttributes(new { @style = "text-align:center;" })
        .HeaderHtmlAttributes(new { @style = "font-weight:bold; text-align:center;" })
        .Filterable(false).Sortable(false).Title("وقت الكشف").Width(100);
    columns.Bound(e => e.Kashf)
        .ClientTemplate("#=Kashf.Kashf_Name#")
        .HtmlAttributes(new { @style = "text-align:center;" })
        .HeaderHtmlAttributes(new { @style = "font-weight:bold; text-align:center;" })
        .Filterable(false).Sortable(false).Title("نوع الكشف").Width(150);
 
    columns.Command(command =>
    {
        command.Edit().HtmlAttributes(new { @class = "my_Editbtn", @style = "margin-left:10px; font-weight:bold;" }).Text("تعديل");
        command.Destroy().HtmlAttributes(new { @class = "my_Delbtn", @style = "font-weight:bold;" }).Text("حذف");
    }).HtmlAttributes(new { @style = "text-align:center;" });
})
       .Pageable()
       .Sortable()
               .Editable(editable => editable.Mode(GridEditMode.PopUp))
       .DataSource(source => source.Ajax()
                    .Model(model =>
                        {
                            model.Id(e => e.ID);
                            model.Field(e => e.ID).Editable(false);
                        })
                  .Events(events => events.Error("error_handler"))
                  .Read(read => read.Action("GetData", "VisitDatas").Data("getAdditionalData"))
                  .Update(update => update.Action("GetData", "VisitDatas").Data("getAdditionalData"))
                  .Destroy(destroy => destroy.Action("GetData", "VisitDatas").Data("getAdditionalData"))
                )
      .Events(e => e.DataBound("dataBound").Edit("onEdit"))
    )
 

and command buttons style is back, but i need rows style "color" back again

so how can i do that please?


Viewing all articles
Browse latest Browse all 94857

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>