PDA

View Full Version : [CLOSED] Add tab dynamically using StringBuilder?



speedstepmem4
Jun 17, 2014, 8:16 AM
Hi,


In Ext 1x we are allowed to add tab dynamically using StringBuilder without mentioning any Layout.


But in Ext 2x, when we add tab using String Builder, an error message gets displayed like "Layout Run Failed"!


Do we need to mention any layout for the gridpanel?


Please guide us with a sample code if available.

Daniil
Jun 17, 2014, 11:21 AM
Hi @speedstepmem4,



Do we need to mention any layout for the gridpanel?

No, you don't.

Please provide a test case to reproduce the problem.

speedstepmem4
Jun 24, 2014, 5:01 AM
Hi Daniil,

Please check the below code part and also the attached error image.




<ext:Viewport ID="ViewPort1" runat="server" Layout="FitLayout">
<Content>
<ext:Container runat="server" ID="BorderLayout1" StyleSpec="background-color:transparent;"
Layout="BorderLayout">
<Items>
<ext:Panel ID="Panel1" runat="server" Border="false" Region="Center" MarginSpec="0 0 0 0">
<Content>
<ext:Container Layout="BorderLayout" ID="BorderLayout3" runat="server">
<Items>
<ext:Panel ID="Panel6" runat="server" Border="false" Height="30" Region="North">
<Content>
<table cellpadding="0" cellspacing="0" border="0" width="100%" class="toolbar">
<tr>
<td>
<table cellpadding="0" cellspacing="0" border="0">
<tr>
<td>
<div id="midle3">
<ul>
<li>
<ext:ImageButton runat="server" ID="btnMarkAsRead" SkinID="tbarMarkAsRead">
<Listeners>
<Click Delay="1" Handler="goMarkasRead();" />
</Listeners>
</ext:ImageButton>
</li>
<li>
<ext:ImageButton runat="server" ID="btnComplete" SkinID="tbarComplete">
<Listeners>
<Click Delay="1" Handler="goComplete();" />
</Listeners>
</ext:ImageButton>
</li>
<li>
<img src='images/blank.png' class='line' alt='' id="img_line" runat="server" /></li>
<li runat="server" id="liQuickLink">
<ext:ImageButton runat="server" ID="imgQuickLink" SkinID="tbarQuickLink">
<Listeners>
<Click Delay="1" Handler="goOpenQuickLink();" />
</Listeners>
</ext:ImageButton>
</li>
<li runat="server" id="liQuickLinkLine">
<img src='images/blank.png' class='line' alt='' /></li>
<li>
<ext:ImageButton runat="server" ID="btnExpExcel" SkinID="tbarExportExcel">
<DirectEvents>
<Click OnEvent="ExportToExcel">
</Click>
</DirectEvents>
</ext:ImageButton>
</li>
<li>
<ext:ImageButton runat="server" ID="btnExpCsv" SkinID="tbarExportCSV">
<DirectEvents>
<Click OnEvent="ExportToCsv">
</Click>
</DirectEvents>
</ext:ImageButton>
</li>
<li>
<ext:ImageButton runat="server" ID="btnExpPdf" SkinID="tbarExportPDF">
<DirectEvents>
<Click OnEvent="ExportToPdf">
</Click>
</DirectEvents>
</ext:ImageButton>
</li>
<li>
<ext:ImageButton runat="server" ID="btnRefresh" SkinID="tbarRefresh">
<Listeners>
<Click Handler="RefreshStore();"></Click>
</Listeners>
</ext:ImageButton>
</li>
</ul>
</div>
</td>
</tr>
</table>
</td>
<td>
<div style="float: right; vertical-align: middle;">
<table border="0" cellpadding="0" cellspacing="0">
<tr>
<td align="right">
<div style="float: left; font-weight: bold; padding-bottom: 5px; padding-right: 5px;"
id="grand_total_text">
<ext:Label ID="lblGrandTotalCaption" runat="server" />
:
</div>
<div style="float: left; padding-bottom: 5px; width: 30px; padding-right: 15px; border-right: solid 1px #aabbcc;"
id="grand_total_value">
</div>
</td>
<td style="width: 20px"></td>
<td align="right">
<div style="float: left; padding-bottom: 5px; padding-right: 5px;" id="grand_new_text">
<img id='imgGrandNew' class='img_new_grand' src='images/icons/new.png' alt='new' />
</div>
<div style="float: left; padding-bottom: 5px; width: 30px; padding-right: 15px; border-right: solid 1px #aabbcc;"
id="grand_new_value">
</div>
</td>
<td style="width: 20px"></td>
<td align="right">
<div style="float: left; padding-bottom: 5px; padding-right: 5px;" id="grand_read_text">
<img id='imgGrandMark' class='img_mark_grand' src='images/icons/pin.png' alt='read' />
</div>
<div style="float: left; padding-bottom: 5px; width: 30px; padding-right: 15px; border-right: solid 1px #aabbcc;"
id="grand_read_value">
</div>
</td>
<td style="width: 10px"></td>
<td align="right" style="padding-right: 7px;">
<div style="padding-bottom: 5px; float: left;">
<ext:ComboBox ID="cmbDashboardVersion" runat="server" Editable="false" AutoPostBack="false"
Width="100">
<Listeners>
<Select Handler="VersionChange();" />
</Listeners>
</ext:ComboBox>
</div>
</td>
</tr>
</table>
</div>
</td>
</tr>
</table>
</Content>
</ext:Panel>
<ext:Panel ID="pnlAccordion" runat="server" Border="false" StyleSpec="width:100%"
Region="Center">
<Content>
<ext:Container Layout="AccordionLayout" ID="accContainer" runat="server">
<Items>
</Items>
</ext:Container>
</Content>
</ext:Panel>
</Items>
</ext:Container>
</Content>
</ext:Panel>
</Items>
</ext:Container>
</Content>
</ext:Viewport>




public class DimPanel : Ext.Net.Panel
{
DashboardGroupingKey _panelKey;


public DashboardGroupingKey PanelKey
{
get { return _panelKey; }
set { _panelKey = value; }
}


}


protected void Page_Load(object sender, EventArgs e)
{
try
{
DimPanel accpanel = null;
StringBuilder sbTitle = null;


if (!Page.IsPostBack)
{


FetchDatasAndGroup(false);
int counter = 1;
resourceManager.AddScript("loadingMessage = '{0}';", LoadingMessage);
string panelKeys = string.Empty;
foreach (var item in ListDashBoardGroup)
{
sbTitle = new StringBuilder();
sbTitle.AppendFormat("<table id='tblTitle{0}' border='0' class='tbl_titile' width='95%'>", counter);
sbTitle.AppendFormat("<tr id='trTitle{0}' class='tr_title'>", counter);


sbTitle.AppendFormat("<td><table><tr>");


sbTitle.AppendFormat("<td id='tdTitleIcon{0}' class='td_icon_title'>", counter);
sbTitle.AppendFormat("<img id='imgTitleIcon{0}' class='img_icon_title' src='{1}' alt='{2}' width='16px' height='16px' />", counter, GetImageSrc(item.Key), "typeHere");
sbTitle.Append("</td>");


sbTitle.AppendFormat("<td id='tdTitleText{0}' class='td_text_title'>", counter);
sbTitle.Append(item.Key.RectypeDesc);
sbTitle.Append("</td>");


sbTitle.AppendFormat("</tr></table></td>");


sbTitle.AppendFormat("<td><table align='right' border='0'><tr>");


sbTitle.AppendFormat("<td id='tdTitleTotal{0}' class='td_total_title'>", counter);
sbTitle.AppendFormat("<div class='label_title'>{2}:</div> <div class='value_title' id='spn_tot_{1}'>{0}</div>", item.Values.Count, counter, CacheCaption.GetCaption("CG-0358"));
sbTitle.Append("</td>");
sbTitle.Append("<td width='20'></td>");
sbTitle.AppendFormat("<td id='tdTitleNew{0}' class='td_new_title'>", counter);
sbTitle.AppendFormat("<div class='image_title'><img id='imgTitleNew{0}' class='img_new_title' src='images/icons/new.png' alt='new' /></div> <div class='value_title' id='spn_new_{1}'>{0}</div>",
item.Values.Count(g => g.EprotexStatus == 1), counter);
sbTitle.Append("</td>");
sbTitle.Append("<td width='20'></td>");
sbTitle.AppendFormat("<td id='tdTitleMarkRead{0}' class='td_mark_title'>", counter);
sbTitle.AppendFormat("<div class='image_title'><img id='imgTitleMark{0}' class='img_mark_title' src='images/icons/pin.png' alt='read' /></div> <div class='value_title' id='spn_mark_{1}'>{0}</div>",
item.Values.Count(g => g.EprotexStatus == 2), counter);
sbTitle.Append("</td>");


sbTitle.AppendFormat("</tr></table></td>");
sbTitle.Append("<td class='td_spacer'></td>");
sbTitle.Append("</tr>");
sbTitle.Append("</table>");




string idPanel = "accPanel" + counter;
accpanel = new DimPanel();
accpanel.PanelKey = item.Key;
accpanel.ID = idPanel;
panelKeys += idPanel + "-" + item.Key.Rectype.ToString() + "," + item.Key.RectypeDesc + "," + item.Key.Order.ToString() + "#";
accpanel.Listeners.BeforeExpand.Handler = string.Format("Mask();PanelClick(item,{0},'{1}',{2},'{3}');", item.Key.Rectype, item.Key.RectypeDesc, item.Key.Order, accpanel.ID); ;
accpanel.Title = sbTitle.ToString();
accpanel.Cls = "dashboard-bg";
accContainer.Items.Add(accpanel);
//accContainer.Layout = BOrder
AddGridToPanel(accpanel, item.Key);
++counter;


}
if (accContainer.Items.Count > 0)
resourceManager.AddScript("currentGridID = '{0}';", accContainer.Items[0].ContentControls[0].ID);
hdnPanelKeys.SetValue(panelKeys);
hdnGridPanelIDS.SetValue(GridPanelIDS);
resourceManager.AddScript("UnMask();");
}


}
catch (Exception ex)
{
ApplicationLog appLog = new ApplicationLog(ApplicationType.Application, ex.TargetSite.DeclaringType.Name, ex.TargetSite.Name);
appLog.Description = string.Format("Message: {0} {1} Stack Trace: {2}", ex.Message, Environment.NewLine, ex.StackTrace);
appLog.WriteLog(true);
}


}

Daniil
Jun 24, 2014, 10:06 AM
Thank you for the test case, but, unfortunately, I cannot run it. It throws a compile error

The type or namespace name 'DashboardGroupingKey' could not be found (are you missing a using directive or an assembly reference?)

speedstepmem4
Jun 24, 2014, 11:03 AM
Hi Daniil,

Sorry for the inconvenience caused. Please refer the below code part.




public class DashboardGroupingKey
{
public DashboardGroupingKey()
{

}
public DashboardGroupingKey(int recType, string recTypeDesc, string area)
{
this.Rectype = recType;
this.RectypeDesc = recTypeDesc;
switch (this.Rectype)
{
case 3:
this.Order = 1;
break;

case 2:
this.Order = 2;
break;

case 1:
this.Order = (area.ToUpper().Trim() == "E") ? 3 : 4;
break;

case 7:
this.Order = 5;
break;

case 4:
this.Order = 6;
break;

case 6:
this.Order = 7;
break;
default:
this.Order = 999999;
break;

}
}

Daniil
Jun 24, 2014, 2:16 PM
Thank you, it helps to get rid of that compiler error, but another appears.

Please post a full, standalone .aspx test case. We should be able to copy, paste and run that test case without any changes from our side.

speedstepmem4
Jun 25, 2014, 8:14 AM
Hi Daniil,

Can you please suggest us why this Layout Run failed issue raises?
As you see in the above mentioned test case provided by us, whether it arises because of building controls in server side?
Can you please guide us by a general clarification?

Thank you!!!

geoffrey.mcgill
Jun 25, 2014, 8:27 AM
The sample you provided does not work.

Post a simplified sample that demonstrates how to reproduce the issue. Remove ALL code that is not directly related to the problem.

If you do not provide a working sample in your next post, we will close this thread and delete any others that you might start related to this problem.

geoffrey.mcgill
Jun 25, 2014, 8:35 AM
Maybe the following thread can be helpful:

http://forums.ext.net/showthread.php?25289