How to fill a table layout in ajax request?

  1. #1

    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):

            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
  2. #2
    Hello @tornador76, are you sure you're using Ext.NET 3?

    By your code, it looks like you are using Ext.NET 1, or even before it, as you have references to Coolite. I'm not sure about Coolite, but as far as Ext.NET 1 is concerned, the Ext JS version with it would be 3.x, so that's probably the case, right?

    Unfortunately that's a very old version, especially being Coolite, and we won't be able to help you with the problem. But we'll move the thread to 1.x help so other users of a closerv version could see your thread and hopefully help you with what you should do.

    Providing runnable, one-page test cases, usually helps us running your code and understanding your problem; this potentially would help also the community to run your code and help; and many times reducing your problem helps you finding the source or ways around the issue you're facing. Here's our forums guidelines, should be worth reviewing:

    - Tips for creating simplified code samples
    - More Information Required
    - Forum Guidelines

    Hope this helps!
    Fabrício Murta
    Developer & Support Expert
  3. #3
    Hello,

    Thank you for the answer, yes I am using extjs 3.4, so that's why I thought that I was using Ext.NET 3 ^^.

    Due to my company rules, I can't give you the full code... So I can only give you the code which build the table layout..
    Hope someone will help me :).

Similar Threads

  1. Replies: 23
    Last Post: Jan 17, 2015, 10:43 AM
  2. Replies: 1
    Last Post: Jul 30, 2013, 3:36 PM
  3. [CLOSED] MVC 4 Razor Table Layout.Table
    By ashleysbuss in forum 2.x Premium Help
    Replies: 2
    Last Post: Jun 18, 2013, 10:39 PM
  4. [CLOSED] Table Layout, 100% width Table
    By sisa in forum 1.x Premium Help
    Replies: 5
    Last Post: May 20, 2011, 6:40 AM
  5. Page_ Ajax Load Complete BUG on Ajax Request
    By jeybonnet in forum 1.x Help
    Replies: 8
    Last Post: Jun 22, 2009, 11:19 AM

Tags for this Thread

Posting Permissions