Nov 29, 2013, 11:52 AM
[CLOSED] how to open partial view with model as parameter from javascript or jquery
Hi,
I am using ext.net partial view which is form panel with tree panel and another panel having child partial view.
Please refer image,
Left side in the image is tree panel and right side is child partial view which contains tpl (XTemplate).
On click of tree node item, need to populate right side tpl (child partial view) againwith different data.
How to do that using javascript or jquery?
To call that partial view from tree node item click , giving $.Ajax call to controller action and fetching list<model> for tpl.But unable to assign or baing that model to child partial view again.
here is 'Shownotehistory' javascript function -
I am using ext.net partial view which is form panel with tree panel and another panel having child partial view.
@(Html.X().FormPanel()
.ID("frm")
.TopBar(Html.X().Toolbar().ID("TopBar").BorderSpec("0 1 1 1")
.Items(
Html.X().Button().ID("imgExportToExcel").Cls("btn export").ToolTip("Export to Excel").Text("Export To Excel"),
Html.X().Button().ID("imgPrint").Cls("btn print").ToolTip("Print").Text("Print")
)
)
.Items(
Html.X().Panel().ID("pnlTree").Layout(LayoutType.HBox).Items(
Html.X().Container().Flex(1).Items(Html.X().TreePanel().Cls("tree-panel").BorderSpec("0 1 0 1")
.Height(350)
.Flex(1)
.Store(
Html.X().TreeStore()
.Proxy(
Html.X().AjaxProxy().Url(Url.Action("GetChildren"))
)
)
.Root(
Html.X().Node().NodeID("0").Text("All Notes")
)
.Listeners(l =>
l.ItemClick.Handler = "ShowNoteHistory(record.data.id,record.data.text);"
)),
Html.X().Panel().ID("pnlTpl").Layout(LayoutType.HBox)
.ItemsFromPartial("ViewNotes", Model)
)
)
)
Please refer image,
Left side in the image is tree panel and right side is child partial view which contains tpl (XTemplate).
On click of tree node item, need to populate right side tpl (child partial view) againwith different data.
How to do that using javascript or jquery?
To call that partial view from tree node item click , giving $.Ajax call to controller action and fetching list<model> for tpl.But unable to assign or baing that model to child partial view again.
here is 'Shownotehistory' javascript function -
var ShowNoteHistory = function (id, text) {
$("#TplNoteHistory").empty();
$.ajax({
url: '@(Url.Action("ShowNoteHistoryByNode","Note"))',
data: { nodeID: id, NodeText: text },
datatype: "json",
type: "GET",
success: function (data) {
//data contains List<model> for tpl (right side partial view)
}
});
};
Controller code :- public ActionResult ShowNoteHistoryByNode(string nodeID, string NodeText)
{
string[] noteDetail = nodeID.Split('_');
string nodeLevel = noteDetail[0];
string levelDataID = noteDetail[1];
List<NoteDTO> notes = new List<NoteDTO>();
int functionalityID = 0;
switch (Convert.ToInt32(nodeLevel))
{
case 1:
functionalityID = 1;
break;
case 2:
functionalityID = 9;
break;
default:
break;
}
notes = coreServiceProxy.ReadAllNote().TheEntity;
NoteDTO note = new NoteDTO();
notes = notes.Where(s => s.FunctionalityId == functionalityID && s.FunctionalityDataId != 0).ToList();
//Ext.Net.MVC.PartialViewResult pr = new Ext.Net.MVC.PartialViewResult();
//pr.ContainerId = "NoteHistoryContainer";
//pr.ViewName = "ViewNotes";
//pr.Model = notes;
//return pr;
return Json(new { success = true, model = notes }, "application/json", Encoding.UTF8, JsonRequestBehavior.AllowGet);
}
Last edited by Daniil; Dec 10, 2013 at 11:47 AM.
Reason: [CLOSED]