Names 、 Gender 、 Age という列がある Telerik MVC Grid があります。Gender にバインドされた ListBox を使用します (SQL 2k8 テーブル "Person" に由来します。エンティティ フレームワーク、POCO クラス、リポジトリ パターンを使用しています)。次に、「検索」として画像ボタンがあります。
ユーザーが ListBox からいくつかの値を選択し、[検索] ボタンを押すと、同じページにある Telerik MVC グリッド (実際の Telerik MVC グリッドを持つユーザー コントロールをレンダリングしています) にデータが入力されます。
これを行う方法 ?選択した ListBox 値をコントローラー アクション "SearchPerson" に戻す方法。JQuery を使用してこれを行う方法があります。しかし、これを行う方法がわかりません。私を助けてください
編集:コード
<% using (Ajax.BeginForm("SearchVouDate", "ERA", new AjaxOptions { UpdateTargetId = "ProfileList", LoadingElementId = "LoadingImage", OnSuccess = "ShowMessage" }))
{ %>
<div class="SelectNPI" >
<div class="DivSelectNPI">
<input name="selection1" value="NPI" id="rdNPI" type="radio" onclick="toggleLayer(this.checked);" />
<%:Html.Label(Resources.Strings.SelectNPI) %>
<div id="ERANPI" style="display: none;" >
<%:Html.ListBoxFor(m => m.Eras.NPI, new MultiSelectList(Model.GetERAs, "NPI", "NPI", Model.NPIListBox), new { ID="NPIList", style = "width: 160px; height:50px" })%>
</div>
</div>
<div class="SelectPIN">
<input name="selection1" type="radio" id="rdPIN" value="PIN" onclick="toggleLayer1(this.checked);" />
<%:Html.Label(Resources.Strings.SelectPIN) %>
<div id="ERAPIN" style="display: none;" >
<%:Html.ListBoxFor(m => m.Eras.PIN, new MultiSelectList(Model.GetERAs, "PIN", "PIN", Model.PINListBox), new {ID="PINList", style = "width: 180px; height:50px" })%>
</div>
</div>
</div>
<input type="submit" class="btnSearchSubmit" id="PaySearchDateSubmit" name="PaySearchDateSubmit" value="Search" />
</div>
</div>
<%} %>
<br /><br />
<div class="ERATopDiv" > <label id="Label1" class="lblSearchResult"> Search By Check Number</label> </div>
<br />
<div class="ERATopDiv"><label id="Label3" class="lblSearchResult" >Search Result</label> </div>
<div id="ProfileList">
<%Html.RenderPartial("SearchVoucherNum"); %>
</div>
<div id="results">
</div>
</div>
<div id="EraPopupWindow">
</div>
私のコントローラー:
[HttpPost]
public ActionResult SearchVouDate(ERAViewModel era, FormCollection formValues)
{
try
{
if (formValues["Eras.NPI"] != null)
{
era.NPIListBox = formValues["Eras.NPI"].Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries);
string[] selectedNPI = era.NPIListBox;
ERAViewModel ervm = new ERAViewModel();
foreach (string NPI in selectedNPI)
{
ervm = this.WorkerService.SearchByNPI(formValues);
return PartialView("SearchVoucherNum", ervm);
}
}
else
{
ERAViewModel eras = this.WorkerService.SearchByPIN(era.Eras.PIN);
return PartialView("SearchVoucherNum", eras);
}
}
catch (Exception ex)
{
bool reThrow = ExceptionPolicyWrapper.HandleException(ex, ExceptionPolicies.MVCPolicy);
if (reThrow)
throw;
}
return null;
}
メイン ビューでレンダリングしている PartialView (メイン ビューには ListBox が含まれ、 partialView にはテレリック MVC グリッドが含まれます)
<% Html.Telerik().Grid(Model.GetERAs)
.Name("ERA").TableHtmlAttributes(new { style = "height:20px" })
.Scrollable(scroll => scroll.Enabled(true))
.DataKeys(datakeys => datakeys.Add(m => m.EraId))
.Columns(columns =>
{
columns.Bound(m => m.NPI).Title(Resources.Strings.NPI).Width(150)
.HtmlAttributes(new { style = "text-align:center" })
.HeaderHtmlAttributes(new { style = "color:black; margin:0 0 0 0; padding-left:15px; background-color:#BDBDBD; text-align:center; border-right:grey" });
columns.Bound(m => m.PIN).Title(Resources.Strings.PIN).Width(150)
.HeaderHtmlAttributes(new { style = "color:black; margin:0 0 0 0; padding-left:15px; background-color:#BDBDBD; text-align:center; border-right:grey" })
.HtmlAttributes(new { style = "text-align:center" });
columns.Bound(m => m.GroupName).Title(Resources.Strings.GroupName).Width(150)
.HeaderHtmlAttributes(new { style = "color:black; margin:0 0 0 0; padding-left:15px; background-color:#BDBDBD; text-align:center; border-right:grey" })
.HtmlAttributes(new { style = "text-align:center" });
columns.Bound(m => m.CheckNo).Title(Resources.Strings.CheckNo).Width(100)
.HeaderHtmlAttributes(new { style = "color:black; margin:0 0 0 0; padding-left:15px; background-color:#BDBDBD; text-align:center; border-right:grey" })
.HtmlAttributes(new { style = "text-align:center" });
columns.Bound(m => m.VoucherNo).Title(Resources.Strings.VoucherNo).Width(150)
.HeaderHtmlAttributes(new { style = "color:black; margin:0 0 0 0; padding-left:15px; background-color:#BDBDBD; text-align:center; border-right:grey" })
.HtmlAttributes(new { style = "text-align:center" });
columns.Bound(m => m.VoucherDate).Title(Resources.Strings.VoucherDate).Format("{0:dd/MM/yyyy}").Width(150)
.HeaderHtmlAttributes(new { style = "color:black; margin:0 0 0 0; padding-left:15px; background-color:#BDBDBD; text-align:center; border-right:grey" })
.HtmlAttributes(new { style = "text-align:center" });
columns.Bound(m => m.PaymentDate).Title(Resources.Strings.PaymentDate).Format("{0:dd/MM/yyyy}").Width(150)
.HeaderHtmlAttributes(new { style = "color:black; margin:0 0 0 0; padding-left:15px; background-color:#BDBDBD; text-align:center; border-right:grey" })
.HtmlAttributes(new { style = "text-align:center" });
columns.Bound(m => m.NonHippaVoucherPath).Title(Resources.Strings.NonHippaVoucherPath).Width(150).Format(Ajax.ActionLink("View Non Hippa voucher", "GetPdffile", "ERA", new { Id = "{0}" }, new AjaxOptions() { UpdateTargetId = "EraPopupWindow", HttpMethod = "Get" }, new { Style = "color:#FF0070;" }).ToString().Replace("{", "{{").Replace("}", "}}")).Encoded(false);
columns.Bound(m => m.HippaVoucherPath).Title(Resources.Strings.HippaVoucherPath).Width(150).Format(Ajax.ActionLink("View Hippa voucher", "GetPdffile", "ERA", new { Id = "{0}" }, new AjaxOptions() { UpdateTargetId = "EraPopupWindow", HttpMethod = "Get" }, new { Style = "color:#FF0070;" }).ToString().Replace("{", "{{").Replace("}", "}}")).Encoded(false);
//columns.Bound(m => m.Non_hippa_voucher_path).HtmlAttributes("color:#8A2BE2").Format(Html.ActionLink("View Non Hippa voucher", "GetPdffile", "ERA", new { ID = "{0}" }, new { onclick = "return someFunction();", Style = "color:#8A2BE2" }).ToHtmlString()).Encoded(false).Title("").Width(150);
//columns.Bound(m => m.Hippa_voucher_path).HtmlAttributes("color:#8A2BE2").Format(Html.ActionLink("View Hippa voucher", "GetFile/", new { ID = "{0}", Style = "color:#8A2BE2" }, "ERA/").ToHtmlString()).Encoded(false).Title("").Width(150);
})
// .ClientEvents(clientEvents => clientEvents.OnDataBinding("dataBinding"))
.DataBinding(databinding => databinding.Ajax().Select("AjaxERA", "ERA"))
.EnableCustomBinding(true)
.Pageable(paging =>{paging.Enabled(true) ;paging.PageSize(5) ;})
.Sortable()
.Filterable()
.Footer(true)
.Render();
%>