May 13, 2019, 9:08 AM
How to fill a table layout in ajax request?
Hello,
I'm trying to fill a table layout when I click on a button.
It works only if I call the ajax method on page_load, not when I click on the button..
Here's my code (js):
I am on ext.net 3, so I cannot use the Render function for the panel.
Thanks for helping
I'm trying to fill a table layout when I click on a button.
It works only if I call the ajax method on page_load, not when I click on the button..
Here's my code (js):
for (i = 0; i < rech_stoCriteresSelectionnes.data.length; i++) {
id = rech_stoCriteresSelectionnes.getAt(i).data.IdCritere;
comp = rech_stoCriteresSelectionnes.getAt(i).data.Comparateur;
valeur = rech_stoCriteresSelectionnes.getAt(i).data.Condition;
break;
}
var canSearch = true;
if (canSearch) {
Coolite.AjaxMethods.GenerePanel(
id, valeur,
{
success: function (result) {
pnlResult.doLayout();
},
eventMask: {
msg: 'Chargement en cours...',
showMask: true,
minDelay: 500
}
});
}
here's where I generate the table layout:private void GeneratePanel(AdoLineWS.Commun.Couple[][] lst, List<AdoLineWS.Commun.Couple> lcpres)
{
foreach (var lcoup in lst)
{
string param = lcoup.Where(x => x.Texte.Equals("Parameter_name")).Select(x => x.Valeur).FirstOrDefault().Substring(1);
if (!param.Equals("OID") && !param.Equals("RETOUR") && !param.Equals("CODE_CLIENT") && !ControlExists(lcoup.Where(x => x.Texte.Equals("Parameter_name")).Select(x => x.Valeur).FirstOrDefault().Substring(1)) && !param.Equals("OID_CLIENT") && !param.Equals("CLIENT"))
{
Cell cell = new Cell();
Coolite.Ext.Web.Label lb = new Coolite.Ext.Web.Label();
lb.Text = lcoup.Where(x => x.Texte.Equals("Parameter_name")).Select(x => x.Valeur).FirstOrDefault().Substring(1);
lb.Hidden = false;
cell.Items.Add(lb);
cell.DataBind();
tabLay.Cells.Add(cell);
string type = lcoup.Where(x => x.Texte.Equals("Type")).Select(x => x.Valeur).FirstOrDefault();
switch (type)
{
case "varchar":
cell = new Cell();
TextField tf = new TextField();
tf.ID = lb.Text;
tf.MaxLength = Int32.Parse(lcoup.Where(x => x.Texte.Equals("Length")).Select(x => x.Valeur).FirstOrDefault());
tf.Value = lcpres.Where(x => x.Texte.Substring(1).Equals(param)).Select(x => x.Valeur).FirstOrDefault();
tf.Hidden = false;
cell.Items.Add(tf);
cell.DataBind();
tabLay.Cells.Add(cell);
break;
case "int":
cell = new Cell();
NumberField nf = new NumberField();
nf.ID = lb.Text;
nf.MaxLength = Int32.Parse(lcoup.Where(x => x.Texte.Equals("Length")).Select(x => x.Valeur).FirstOrDefault());
var res = lcpres.Where(x => x.Texte.Substring(1).Equals(param)).Select(x => x.Valeur).FirstOrDefault();
if (res != "" && res != " ")
{
nf.Text = lcpres.Where(x => x.Texte.Substring(1).Equals(param)).Select(x => x.Valeur).FirstOrDefault();
}
else
{
nf.Text = "0";
}
nf.Hidden = false;
cell.Items.Add(nf);
cell.DataBind();
tabLay.Cells.Add(cell);
break;
default:
break;
}
}
}
pnlResult.DoLayout();
btnDuplicate.Hidden = false;
}
Here's the aspx panel:<ext:Panel ID="pnlResult" runat="server" AutoHeight="true" AutoRender="true">
<Body>
<ext:TableLayout ID="tabLay" runat="server" Columns="8" AutoRender="true">
</ext:TableLayout>
</Body>
</ext:Panel>
The issue is that the table layout isn't updated and is still empty. When I call the function above on page_load, the table layout is loaded but not on ajax call. Why?I am on ext.net 3, so I cannot use the Render function for the panel.
Thanks for helping