我有两个部分视图,一个用于编辑,一个用于ListIndex,其中包含用于列出表格数据的网格。
我想获得更新的ListIndex页面,当"更新"单击“编辑局部视图”窗体上的按钮。
此处页面不会自行更新。只有在刷新页面后,它才会被更新。
以下是ListIndex视图的代码 - LoctionIndex.cshtml
-module(spawn_spammer).
-export([kickoff_many/1]).
kickoff() ->
{ok, Catcher} = spawn_catcher:start(),
{echo, _} = spawn_catcher:process_packet(Catcher, {packet_from, self()}).
kickoff_many(N) ->
lists:foreach(fun(_) -> spawn(fun kickoff/0) end, lists:seq(1, N)).
-module(spawn_catcher).
-behavior(gen_server).
-export([start/0,
process_packet/2,
init/1,
handle_call/3, handle_cast/2, handle_info/2,
terminate/2, code_change/3]).
start() ->
gen_server:start(?MODULE, [], []).
process_packet(Ref, Packet) ->
gen_server:call(Ref, {process_packet, Packet}).
init(_) ->
gen_server:cast(self(), get_ready),
{ok, not_ready}.
handle_cast(get_ready, not_ready) ->
{noreply, ready}.
handle_call({process_packet, P}, _From, ready) ->
{stop, normal, {echo, P}, ready};
handle_call({process_packet, _P}, _From, not_ready) ->
{stop, normal, call_while_not_ready, not_ready}.
handle_info(_, ready) ->
{stop, normal, unexpected, ready}.
terminate(_, _) -> ok.
code_change(_, State, _) -> {ok, State}.
以下是应该更新的用户控件的代码:
@MvcHtmlString.Create(
@grid.GetHtml(
tableStyle: "tablegeneral",
fillEmptyRows: true,
mode: WebGridPagerModes.All,
firstText: "<< First",
previousText: "< Prev",
nextText: "Next >",
lastText: "Last >>",
columns: new[]
{
grid.Column("LOC_NAME","BINNO"),
grid.Column(format: @<text> @Ajax.EditModalDialogActionLink("Edit","Edit","Location","Edit Location","Model",(long)item.LOC_CODE)</text>),
grid.Column(format: @<text> @Ajax.EditModalDialogActionLink("Delete", "Delete","Location", "Delete Location","model",(long)item.LOC_CODE)</text>)
}).ToString().Replace("<tfoot>", "<tfoot> <tr><td colspan=\"7\" align=\"center\"> Records " + firstRecord + " to " + lastRecord + " of " + grid.TotalRowCount + "</tr>"))
这是我的LocationController:
public static MvcHtmlString EditModalDialogActionLink(this AjaxHelper ajaxHelper, string linkText, string actionName, string controller, string dialogTitle, string div, long Locid)
{
var dialogDivId = Guid.NewGuid().ToString();
return ajaxHelper.ActionLink(linkText, actionName, controller, new {id=Locid },
ajaxOptions: new AjaxOptions
{
UpdateTargetId = dialogDivId,
InsertionMode = InsertionMode.InsertAfter,
HttpMethod = "GET",
OnBegin = string.Format(CultureInfo.InvariantCulture, "prepareModalDialog('{0}')", dialogDivId),
OnFailure = string.Format(CultureInfo.InvariantCulture, "clearModalDialog('{0}');alert('Ajax call failed')", dialogDivId),
OnSuccess = string.Format(CultureInfo.InvariantCulture, "openModalDialog('{0}', '{1}')", dialogDivId, dialogTitle)
});
}