This is a migrated thread and some comments may be shown as answers.

Closing Window With Condition

1 Answer 81 Views
Window
This is a migrated thread and some comments may be shown as answers.
Ahmad
Top achievements
Rank 1
Ahmad asked on 29 Dec 2012, 08:59 AM
I have Kendo Grid and used a window for editing.
i want closing window with condition.

if (person.FName =="Jone")
 close window
else
 msgbox "You can not Closing this window!"

how to do?


my controller:
public ActionResult UpdatePerson([DataSourceRequest] DataSourceRequest dsRequest, PersonViewModel person)
     {           
         if (person != null && ModelState.IsValid)
         {
             var db = new PersonDBEntities();

         //... Condition
                //   if (person.FName =="Jone")
                //......
                //........

             var toUpdate = db.tblPerson.FirstOrDefault(p => p.PersonID == person.PersonID);
 
             if (toUpdate != null)
             {
                 toUpdate.FName = person.FName;
                 toUpdate.LName = person.LName;
                  db.SaveChanges();
             }
         }
         return Json(ModelState.ToDataSourceResult());
     }
and Index Form:
@{
    ViewBag.Title = "Person";
}
 
@(Html.Kendo().Grid<KendoMVCWrappers.Models.PersonViewModel>().Name("persons")
    .DataSource(dataSource => dataSource
        .Ajax()
        .Model(model=>model.Id(m=>m.PersonID))
        .Read(read => read.Action("GetPersons", "Person"))
        .Create(up => up.Action("CreatePerson", "Person"))
        .Update(up => up.Action("UpdatePerson", "Person"))
        .Destroy(del => del.Action("DeletePerson", "Person"))
             
    )
    .ToolBar(cmd => cmd.Create().Text("Add"))           
    .Columns(columns =>
    {
        columns.Bound(c => c.FName).Width(100);
        columns.Bound(c => c.LName).Width(200);
        columns.Command(cmd =>
        {
            cmd.Edit().UpdateText("Save").CancelText("Cancel").Text("Detail");
            cmd.Destroy().Text("Del");
        });
         
         
    })
        
    .Pageable()
    .Selectable(sel => sel.Mode(GridSelectionMode.Single))
    .Filterable()
    .Sortable()
    .Editable(ed=>ed.Mode(GridEditMode.PopUp).TemplateName("PersonDetail").Window(w => w.Title("Detail")))      
)


and PersonDetail:
@model KendoMVCWrappers.Models.PersonViewModel
 
    <div class="k-content">
        <div id="detail">
            <ul>
                <li>
                    <label for="fname" class="required">First Name</label>
                    <input type="text" id="fname" name="fname" class="k-textbox" data-bind="value: FName" /> 
                </li>
                <li>
                    <label for="lname">Last Name</label>
                    <input id="lname" name="lname" type="number" class="k-textbox" data-bind="value: LName"/>
                </li>
                <li style="height:250px">
                </li>
            </ul>
        </div>
</div>

please hel me.

1 Answer, 1 is accepted

Sort by
0
Petur Subev
Telerik team
answered on 01 Jan 2013, 02:04 PM
Hello Ahmad,

I do not fully understand you question because after that part with the comments inside of the controller action the window is anyway going to close.

I assume that you want to show validation message with server validation - to do so please take a detail look at this code library article.

Regards,
Petur Subev
the Telerik team
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
Tags
Window
Asked by
Ahmad
Top achievements
Rank 1
Answers by
Petur Subev
Telerik team
Share this question
or