Hi everybody,
I am using a Telerik grid to display my 'applicatioin' records which are stored in MS-SQL server2005, and I used Entity Framework 4. Everything is fine to insert, update,delete the data when only one user performed this.
But I have a trouble here when multiple users do this. For instance the following scenario:
- User A and User B are exploring the same page of my grid at this moment( of course, they saw the records)
- Now User A delete a record, let's say its Id is '100'.( so record 100 does not exist in database any more after this deletion)
- User B doesn't know record 100 has actually been deleted by A, Then user B just try to edit record 100, he clicked the 'update' button in hoping of poping up the editing window to modify data. But in fact, the popup window becomes a strang empty div since there is no data to render.(it cannot retrieve record 100 from database)
The strange empty div is exact my problem! How to avoid this happening. (when there is no data to render should display a message telling the user what's hanppening rather than a strange div,you can see it from attachment.)
I think this is a very common scenario with concurrency operation, Could some one tell me how you deal this prolem?? Maybe I need add some client events to handle this.
Thanks a lot in advance!!!
The view is like this:
@model IEnumerable<DataModel.Models.Application> @{ ViewBag.Title = "Index"; } @helper Gridzone() { @(Html.Telerik().Grid(Model).Name("Grid") .Selectable() .ClientEvents(events => events.OnRowSelect("onRowSelected")) //.ClientEvents(events => events.OnRowDataBound("OnDataBound").OnDelete("Grid_onDelete")) .Pageable() .Sortable() .Scrollable() .Pageable() .Filterable() .Resizable(resizing => resizing.Columns(true)) .Reorderable(reorder => reorder.Columns(true)) .DataKeys(keys => keys.Add(g => g.Id).RouteKey("MyId")) .Editable(editing => editing.Mode(GridEditMode.PopUp)) .ToolBar(commands => { if (Roles.IsUserInRole("Administrators")) { commands.Insert(); } }) .DataBinding(dataBinding => dataBinding.Server() .Select("Index", "Application") .Insert("Insert", "Application") .Update("Update", "Application") .Delete("Delete", "Application")) .Columns(columns => { columns.Bound(g => g.Id).Width(50).ReadOnly(); columns.Bound(g => g.ApplicationCategory.Name).Title("Category").Width(120); columns.Bound(g => g.Name); columns.Bound(g => g.Description); if(Roles.IsUserInRole("Administrators")) { columns.Command(command => { command.Edit().ButtonType(GridButtonType.ImageAndText); command.Delete().ButtonType(GridButtonType.ImageAndText); }).Width(190); } }) ) } The popup window templete(to insert/update) is as below:
@model DataModel.Models.Application <fieldset> <legend>Application</legend> @Html.HiddenFor(model => model.Id) <div class="editor-label"> @Html.LabelFor(model => model.Name) </div> <div class="editor-field"> @Html.EditorFor(model => model.Name) @Html.ValidationMessageFor(model => model.Name) </div> <div class="editor-label"> @Html.LabelFor(model => model.Description) </div> <div class="editor-field"> @Html.EditorFor(model => model.Description) @Html.ValidationMessageFor(model => model.Description) </div> <div class="editor-label"> @Html.LabelFor(model => model.ApplicationCategoryId) </div> <div class="editor-field"> @Html.EditorFor(model => model.ApplicationCategoryId) @Html.ValidationMessageFor(model => model.ApplicationCategoryId) </div> </fieldset>