Jan 12, 2016, 12:55 PM
How to save view script to js file
Hi all,
I want to save views (as Ext.Net.PartialViewResult returns) script into js file as a function and call that function instead of request from server for showing that view.
i.e on mvc example "Ajax_Linked_Combos" page http://mvc.ext.net/#/Form_ComboBox/Ajax_Linked_Combos/
when you click "Source Code" button, a request post to http://mvc.ext.net/Source/GetSourceTabs and get this as response
i found ComponentLoader.ToConfig(AbstractComponent component, bool registerResources) method and i thought something like
I want to save views (as Ext.Net.PartialViewResult returns) script into js file as a function and call that function instead of request from server for showing that view.
i.e on mvc example "Ajax_Linked_Combos" page http://mvc.ext.net/#/Form_ComboBox/Ajax_Linked_Combos/
when you click "Source Code" button, a request post to http://mvc.ext.net/Source/GetSourceTabs and get this as response
{script:"Ext.net.ResourceMgr.destroyCmp(\"App.tpwe1086434434\");App.we1086434434.add({id:\"tpwe1086434434\",border:false,xtype:\"tabpanel\",items:[{id:\"tptwe10864344340\",loader:{loadMask:{showMask:true},paramsFn:function(){ return {\"file\":\"/Areas/Form_ComboBox/Views/Ajax_Linked_Combos/Index.cshtml\"}; },renderer:\"frame\",url:\"/Source/GetSourceFile\"},title:\"Index.cshtml\",iconCls:\"#PageWhiteCode\"},{id:\"tptwe10864344341\",loader:{loadMask:{showMask:true},paramsFn:function(){ return {\"file\":\"/Areas/Form_ComboBox/Controllers/Ajax_Linked_CombosController.cs\"}; },renderer:\"frame\",url:\"/Source/GetSourceFile\"},title:\"Ajax_Linked_CombosController.cs\",iconCls:\"#PageWhiteCsharp\"},{id:\"tptwe10864344342\",loader:{loadMask:{showMask:true},paramsFn:function(){ return {\"file\":\"/Areas/Form_ComboBox/Models/Ajax_Linked_CombosModel.cs\"}; },renderer:\"frame\",url:\"/Source/GetSourceFile\"},title:\"Ajax_Linked_CombosModel.cs\",iconCls:\"#PageWhiteCsharp\"}],activeTab:0});"}
i want to save this as a js function in a file, if possible after buildfunction getSourceTabs() {
Ext.net.ResourceMgr.destroyCmp("App.tpwe1086434434");App.we1086434434.add({id:"tpwe1086434434",border:false,xtype:"tabpanel",items:[{id:"tptwe10864344340",loader:{loadMask:{showMask:true},paramsFn:function(){ return {"file":"/Areas/Form_ComboBox/Views/Ajax_Linked_Combos/Index.cshtml"}; },renderer:"frame",url:"/Source/GetSourceFile"},title:"Index.cshtml",iconCls:"#PageWhiteCode"},{id:"tptwe10864344341",loader:{loadMask:{showMask:true},paramsFn:function(){ return {"file":"/Areas/Form_ComboBox/Controllers/Ajax_Linked_CombosController.cs"}; },renderer:"frame",url:"/Source/GetSourceFile"},title:"Ajax_Linked_CombosController.cs",iconCls:"#PageWhiteCsharp"},{id:"tptwe10864344342",loader:{loadMask:{showMask:true},paramsFn:function(){ return {"file":"/Areas/Form_ComboBox/Models/Ajax_Linked_CombosModel.cs"}; },renderer:"frame",url:"/Source/GetSourceFile"},title:"Ajax_Linked_CombosModel.cs",iconCls:"#PageWhiteCsharp"}],activeTab:0});
}
and not request to server to get this view, but just call this function.i found ComponentLoader.ToConfig(AbstractComponent component, bool registerResources) method and i thought something like
public class ViewsJs
{
public static string test()
{
var win=
X.Window().Title("Test")
.Items(
X.Panel()
.Items(
X.TextField()
)
).ToCOmponent();
var result=ComponentLoader.ToConfig(win,true);
return result;
}
}
and use this function to get script, but it returns "x.res" etc as result. how can i get script like PartilaViewResult returns, if possible after build.