This is a migrated thread and some comments may be shown as answers.
Loading a PartialPage inside a TabStrip after Postback from ComboBox doesn't render parent
3 Answers 15 Views
This is a migrated thread and some comments may be shown as answers.
Lukasz
Top achievements
Rank 1
Lukasz asked on 13 Jan 2019, 02:11 AM

Hi, I'm using a Grid inside a TabStrip and a Combobox for filtering. First time it loads correctly, but after I do a postback from the ComboBox it loads only the PartialPage instead of reloading the Partial inside the TabStrip.

div class="btn-group">
    @using (Ajax.BeginForm("Rules", new AjaxOptions { HttpMethod = "POST", UpdateTargetId = "Rules", InsertionMode = InsertionMode.Replace }))
    {
        @Html.AntiForgeryToken()
        <label>Account No</label>
        @(Html.Kendo().DropDownList()
                                              .Name("selectedAccountNo")
                                              .DataTextField("Value")
                                              .DataValueField("Text")
                                              .BindTo(Model.selectedAccNo)
                                              .HtmlAttributes(new { style = "width: 100%" })
        ) 
        <br />
 
 
        <label> Application </label>
        @(Html.Kendo().DropDownList()
                                              .Name("selectedAppNo")
                                              .DataTextField("Value")
                                              .DataValueField("Text")
                                              .BindTo(Model.selectedAppNo)
                                              .HtmlAttributes(new { style = "width: 100%", @onchange = "this.form.submit();" })
        )
    }
</div>
01.[HttpPost]
02.[ValidateAntiForgeryToken]
03.public ActionResult Rules(string selectedAccountNo = "", string selectedAppNo = "")
04.{
05.    var rules = from rule in _db.Rules
06.                select rule;
07. 
08.    var ruletypes = from rTypes in _db.RuleTypes
09.                   select rTypes.RuleType1;
10. 
11.    var vm = new RuleListAndSearchVM(_db);
12.    var rulesVm = new List<RuleVM>();
13. 
14.    ViewBag.Title = "Rules";
15. 
16.    
17.    var ruleTypes = _db.RuleTypes.AsNoTracking().Select(n => new SelectListItem { Value = n.RuleTypeId.ToString(), Text = n.RuleType1 }).ToList();
18.    ViewBag.RuleType = ruleTypes;
19.    TempData.ContainsKey("RuleType");
20.    vm.RuleType = ruleTypes;
21.   
22.    List<SelectListItem> appNumbers = _db.Rules.AsNoTracking().Select(n => new SelectListItem { Value = n.AppNo, Text = n.AppNo }).ToList();
23.    List<SelectListItem> accNumbers = _db.Rules.AsNoTracking().Select(n => new SelectListItem { Value = n.AccNo, Text = n.AccNo }).ToList();
24.    vm.selectedAppNo = appNumbers;
25.    vm.selectedAccNo = accNumbers;
26.     
27.    if (!String.IsNullOrEmpty(selectedAccountNo))
28.    {
29.        rules = rules.Where(acc => acc.AccNo == selectedAccountNo);
30.    }
31.    if (!String.IsNullOrEmpty(selectedAppNo))
32.    {
33.        rules = rules.Where(acc => acc.AppNo == selectedAppNo);
34.    }
35. 
36.   
37.    foreach (var r in rules)
38.    {
39.        var newRule = new RuleVM() { AccNo = r.AccNo, AppNo = r.AppNo, RuleId = r.RuleId, RuleType = new RuleTypeVM() { RuleTypeId = r.RuleTypeId }, RuleValue = r.RuleValue, CreatedBy = new UserVM() { UserId = r.CreatedBy }, DateCreated = r.DateCreated };
40. 
41.        if (r.Status == true)
42.            newRule.Status = "Active";
43.        else
44.            newRule.Status = "Deleted";
45. 
46.        newRule.RuleType.RuleType = _db.RuleTypes.Find(newRule.RuleType.RuleTypeId).RuleType1;
47.        newRule.CreatedBy.Username = _db.Users.Find(newRule.CreatedBy.UserId).Username;
48.        rulesVm.Add(newRule);
49. 
50.    }
51. 
52.    vm.Data = rulesVm;
53. 
54.    vm.SelectedAccNo = selectedAccountNo;
55.    vm.SelectedAppNo = selectedAppNo;
56. 
57.    if (!string.IsNullOrEmpty(selectedAccountNo) || !string.IsNullOrEmpty(selectedAppNo))
58.    {
59.        View("RulesPartial", vm).ExecuteResult(this.ControllerContext); 
60.        return View("RulesPartial", vm);
61.    }
62. 
63.    return new HttpStatusCodeResult(HttpStatusCode.BadRequest);
64. 
65.}

3 Answers, 1 is accepted

Sort by
0
Lukasz
Top achievements
Rank 1
answered on 13 Jan 2019, 02:16 AM

And In the _Layout page:

<div class="form-header">
       <div class="md-sidenav-left" id="v-pills-tab" role="tablist" aria-orientation="vertical">
           @(Html.Kendo().Button()
                 .Name("Home")
                 .HtmlAttributes(new {type = "button", @class = "k-primary", href = "../Home/#"})
                 .Content("Home")
                 .Events(ev => ev.Click("onHomeClick")))
           @(Html.Kendo().Button()
                 .Name("Admin")
                 .HtmlAttributes(new {type = "button", @class = "k-primary", href = "../Admin/#"})
                 .Content("Admin")
                 .Events(ev => ev.Click("onAdminClick")))
           @(Html.Kendo().Button()
                 .Name("Operator")
                 .HtmlAttributes(new {type = "button", @class = "k-primary", href = "../Operator/#"})
                 .Content("Operator")
                 .Events(ev => ev.Click("onOperatorClick")))
 
       </div>
   </div>
0
Lukasz
Top achievements
Rank 1
answered on 13 Jan 2019, 02:16 AM

And In the _Layout page:

<div class="form-header">
       <div class="md-sidenav-left" id="v-pills-tab" role="tablist" aria-orientation="vertical">
           @(Html.Kendo().Button()
                 .Name("Home")
                 .HtmlAttributes(new {type = "button", @class = "k-primary", href = "../Home/#"})
                 .Content("Home")
                 .Events(ev => ev.Click("onHomeClick")))
           @(Html.Kendo().Button()
                 .Name("Admin")
                 .HtmlAttributes(new {type = "button", @class = "k-primary", href = "../Admin/#"})
                 .Content("Admin")
                 .Events(ev => ev.Click("onAdminClick")))
           @(Html.Kendo().Button()
                 .Name("Operator")
                 .HtmlAttributes(new {type = "button", @class = "k-primary", href = "../Operator/#"})
                 .Content("Operator")
                 .Events(ev => ev.Click("onOperatorClick")))
 
       </div>
   </div>
0
Lukasz
Top achievements
Rank 1
answered on 14 Jan 2019, 02:21 AM
Solved using grid filtering.
Asked by
Lukasz
Top achievements
Rank 1
Answers by
Lukasz
Top achievements
Rank 1
Share this question
or