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

[Solved] Grid Ajax Binding inside modal telerik window

1 Answer 75 Views
Grid
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Atanu
Top achievements
Rank 1
Atanu asked on 02 Jun 2012, 07:51 AM
I am facing a strange problem while doing an ajax binding of a grid inside a modal popup window.
The ajax call of the grid not getting called after doing search. What's wrong in the code... Please help

View :

@model IEnumerable<MvcApplicationMIS.Models.NpIniProcessGroupDTO>
         
<div>
    @{Html.Telerik().Window()
        .HtmlAttributes(new { @class = "starnet-window" })
        .Visible(false)
        .Name("PopupProcessGrp")
        .Title("Process Group")
        .Draggable(true)
        .Modal(true)
        .Buttons(b => b.Close())
        .Content
        (
            @<text>
                <div class="panel">
                    <div class="panel_hd">
                        <h3>Process Group</h3>
                    </div>
                    <div class="panel_divider">
                    </div>
                    <div class="panel_body" style="display: block">
                        <div>
                            @using (Ajax.BeginForm("SearchProcessGrp", "Home", new AjaxOptions()
                            {
                                UpdateTargetId = "divGridProcessGrps"
                            }))
                            {
                                <div class="inner_panel" style="width: 69%;">
                                    <div class="inner_panel_hd">
                                        <h4>Search Criteria</h4>
                                    </div>
                                    <div class="inner_panel_divider1"></div>
                                    <div class="inner_panel_divider2"></div>
                                    <div class="inner_panel_body">
                                        <div>
                                            Process Group:
                                            @Html.TextBox("txtProcessGrp")
                                            <input class="t-button" type="submit" id="btnSearch" value="Search" />  
                                        </div>
                                    </div>
                                </div>
                 
                                <div class="inner_panel" style="width: 99%;">
                                    <div class="inner_panel_hd">
                                        <h4>Search Result(s)</h4>
                                    </div>
                                    <div class="inner_panel_divider1"></div>
                                    <div class="inner_panel_divider2"></div>
                                    <div class="inner_panel_body">
                                        <div id="divGridProcessGrps">
                                            @{
                                                Html.Telerik().Grid(Model)
                                                    .Name("ProcessGroupGrid")
                                                    .HtmlAttributes(new { style = "width: 100%;" })
                                                    .NoRecordsTemplate("-")
                                                    .DataKeys(dataKeys =>
                                                    {
                                                        dataKeys.Add(i => i.process_grp);
                                                    })
                                                    .Columns(col =>
                                                    {
                                                        col.Bound(i => i.process_grp).Title("Process Group").HeaderHtmlAttributes(new { style = "text-align:center;" });
                                                    })
                                                    .DataBinding(dataBinding =>
                                                    {
                                                        dataBinding.Ajax().Select("_LoadDataProcessGrp", "Home",
                                                            new
                                                            {
                                                                strPrGrp = ViewBag.ProcessGrp
 
                                                            }).Enabled((bool)ViewBag.IsAjax);
                                                    })
                                                    .Resizable(resizing => resizing.Columns(true))
                                                    .Selectable()
                                                    .Pageable()
                                                    .Sortable()
                                                    .Render();
                                            }
                                        </div>
                                    </div>
                                </div
                            }
                        </div>
                    </div>
                    <div class="clearer">
                    </div>
                </div>                  
            </text>
        )
        .Width(590)
        .Height(350)
        .Render();
    }
</div>

Controller:

public ActionResult SearchProcessGrp(string txtProcessGrp)
 {
     ViewBag.IsAjax = true;
     ViewBag.ProcessGrp = txtProcessGrp;
 
     return PartialView("ProcessGroup");
 }
 
 [GridAction]
 public ActionResult _LoadDataProcessGrp(string strPrGrp)
 {
      
         ViewBag.IsAjax = false;
 
         NpIniProcessGroupDTO obj = new NpIniProcessGroupDTO();
 
         return View("ProcessGroup", new GridModel<NpIniProcessGroupDTO>
         {
             Data = obj.getIniProcesGroup(strPrGrp)
         });
     
 }

Any help will be greatly appreciated

1 Answer, 1 is accepted

Sort by
0
Atanu
Top achievements
Rank 1
answered on 02 Jun 2012, 02:20 PM
Sorry .. silly mistake ... got it right this time....
Working fine now as expected
Tags
Grid
Asked by
Atanu
Top achievements
Rank 1
Answers by
Atanu
Top achievements
Rank 1
Share this question
or