PDA

View Full Version : [CLOSED] Add panel with tabmenu in AjaxResult



Tactem
Jun 02, 2014, 1:45 PM
Hi guys,

I 'd like to dynamically add a panel with a tabMenu in Ajax. Actually, I can add my panel without my tabMenu.

My ajaxresult function


public AjaxResult AddDashTab(string url, string idTab, string title)
{
AjaxResult response = new Ext.Net.MVC.AjaxResult();
var tabPanel = this.GetCmp<TabPanel>("PanelTab");
Panel panel = new Panel { ID = idTab, Title = title, IconCls = "DashboardIcon", Closable = true, Border = false, Layout = LayoutType.Fit.ToString() };
ComponentLoader loader = new ComponentLoader { Url = url, Mode = LoadMode.Frame };
loader.LoadMask.ShowMask = true;
loader.LoadMask.Msg = _resourcesService.GetResource("Javascript", "PreparingDisplay");
panel.Loader = loader;
string menuName = string.Format("MenuTab{0}", idTab);
MenuPanel menu = new MenuPanel(){ID=menuName};
menu.Menu.Add(new MenuItem() { Text = "test" });
panel.AddTo(tabPanel);
panel.Items.Add(menu);
tabPanel.SetActiveTab(idTab);
//response.Script = menu.ToScript(RenderMode.AddTo, menuName);
response.Script += panel.ToScript(RenderMode.AddTo, idTab);


return response;
}

my call


Ext.net.DirectMethod.request({
url: AppPath + "DashboardConfig/AddDashTab",
contentType: 'application/json; charset=utf-8',
type: 'POST',
params: {
url: urlFrame,
idTab: idTab,
title: type
},
success : function (result) {
tabPanel.setActiveTab(idTab);
}
});

Do you know how to show the tabMenu ?

Regards

Daniil
Jun 02, 2014, 2:18 PM
Hi @Tactem,

Please follow:
http://forums.ext.net/showthread.php?15196&p=64310&viewfull=1#post64310

Tactem
Jun 06, 2014, 9:02 AM
Hi Dannil,

sorry for my response late.

I test this exemple with my direct call in js and I don't see my tab.

I must call my direct method in js, I have some treatment before.

Regards

Daniil
Jun 06, 2014, 10:10 AM
Please provide a test case to reproduce.

Tactem
Jun 10, 2014, 8:16 AM
Hi Daniil

this is my sample to reproduce my problem

Controleur


public ActionResult Test()
{
return View();

}

public AjaxResult AddTab(string idTab, string url)
{
AjaxResult response = new Ext.Net.MVC.AjaxResult();
var tabPanel = this.GetCmp<TabPanel>("tetst");
Panel panel = new Panel { ID = idTab, Title = "test", Closable = true, Border = false, Layout = LayoutType.Fit.ToString() };
ComponentLoader loader = new ComponentLoader { Url = url, Mode = LoadMode.Frame };
loader.LoadMask.ShowMask = true;
loader.LoadMask.Msg = "PreparingDisplay";
panel.Loader = loader;
string menuName = string.Format("MenuTab{0}", idTab);
Menu menu = new Menu() { ID = menuName };
MenuItem menuRefresh = new MenuItem() { Text = "Refresh" };
menu.Add(menuRefresh);
panel.TabMenu.Add(menu);
panel.AddTo(tabPanel);
//tabPanel.Add(panel);

//panel.Render();

tabPanel.SetActiveTab(idTab);
response.Script = menu.ToScript(RenderMode.AddTo, menuName);
response.Script += panel.ToScript(RenderMode.AddTo, idTab);


return response;
}

View


@using Ext.Net;
@using Ext.Net.MVC;

@Html.X().ResourceManager(ViewBag.ManagerConfig as MvcResourceManagerConfig).ShowWarningOnAjaxFailure (false)

<script type="text/javascript">
var testAddTab = function() {
var id = 'test';
var urlFrame = 'http://www.ext.net';
Ext.net.DirectMethod.request({
url: "AddTab",
contentType: 'application/json; charset=utf-8',
type: 'POST',
params: {
url: urlFrame,
idTab: id
}
});
};
</script>
@(
Html.X().Viewport()
.Layout(LayoutType.Fit)
.Items
(
Html.X().TabPanel()
.ID("tetst")
.Buttons
(
Html.X().Button()
.Text("test")
.Listeners(p => p.Click.Fn = "testAddTab")
)
)
)

Daniil
Jun 10, 2014, 1:57 PM
Please re-read the item #2 in the post that I mentioned.


Please follow:
http://forums.ext.net/showthread.php?15196&p=64310&viewfull=1#post64310

Tactem
Jun 10, 2014, 2:37 PM
Thank, i forgot this point
TabMenu control is plugin (it is not menu) therefore instance of TabMenu must be added to Plugins section of TabPanel during initial page load (it will be added automatically if there are initial tabs with TabMenu)