[CLOSED] Loop through TemplateHtml in RowExpander

  1. #1

    [CLOSED] Loop through TemplateHtml in RowExpander

    I am take http://mvc.ext.net/#/GridPanel_RowExpander/Remote_Mode/ as an example .

    and change GetData() function like bellow for multiple return value and show in RowExpander's TemplateHtml ,currently in example it will return single value display,How I display multiple records after expand?




    public ActionResult GetData(string company, int index)
            {
               
                var Questions = new List<jr>
            {
                new jr {company = "s1", index = "Q1,Q2",time=DateTime.Now.ToLongTimeString()},
                new jr {company = "s2", index = "Q1,Q2,Q3",time=DateTime.Now.ToLongTimeString()},
                new jr {company = "s3", index = "Q1,Q2,Q4",time=DateTime.Now.ToLongTimeString()},
                new jr {company = "s4", index = "Q1,Q2,Q5",time=DateTime.Now.ToLongTimeString()},
            };
    
                JsonResult _jr = new JsonResult();
                _jr.Data = Questions;
                return _jr;
            }

    RowExpander inside grid.where I add the loop in TemplateHtml

     .Plugins(
                    Html.X().RowExpander()
                    .Loader(Html.X().ComponentLoader()
                            .Mode(LoadMode.Data)
                            .Url(Url.Action("GetData"))
                            .LoadMask(mask => mask.ShowMask = true)
                            .Params(
                                new
                                {
                                    company = JRawValue.From("this.record.data['company']"),
                                    index = JRawValue.From("this.grid.store.indexOf(this.record)")
                                }
                            )
                        )
                        .TemplateHtml(@<text>
                            <span class="template">
                               Company: {company}, Row №: {index}, Server Date: {time}
                            </span>
                        </text>)
                )
    Last edited by matrixwebtech; Nov 05, 2014 at 12:02 PM.
  2. #2
    Hi @matrixwebtech,

    I would recommend to investigate the docs for XTemplate.
    http://docs.sencha.com/extjs/4.2.1/#!/api/Ext.XTemplate

    Specifically, to iterate an array, please use:
    <tpl for=".">
        ...template for each item goes here...
    </tpl>
    Regarding to the example that you mentioned, you could define such a template:
    @<text>
        <tpl for=".">
            <div class="template">Company: {company}, Row #: {index}, Server Date: {time}</div>
        </tpl>
    </text>
    and return such the data:
    public ActionResult GetData(string company, int index)
    {
        return this.Json(new object[]
        {   
            new
            {
                company = company + "0",
                index = index,
                time = DateTime.Now.ToLongTimeString()
            },
            new
            {
                company = company + "1",
                index = index + 1,
                time = DateTime.Now.ToLongTimeString()
            },
            new
            {
                company = company + "2",
                index = index + 2,
                time = DateTime.Now.ToLongTimeString()
            }
        });
    }
  3. #3
    Hi daniil thanks for your help.

    I am very much surprised to look that a for loop can be done like this.relay Ext.net made things easy and simple.Thanks to all EXT.Net team members.
    Last edited by matrixwebtech; Nov 05, 2014 at 12:02 PM.

Similar Threads

  1. Store.Reload loop
    By mj.daly in forum 1.x Help
    Replies: 3
    Last Post: Oct 25, 2013, 4:38 PM
  2. Loop into an existing treepanel
    By springrider in forum 2.x Help
    Replies: 1
    Last Post: May 17, 2012, 3:46 AM
  3. gridpanel loop
    By maxdiable in forum 1.x Help
    Replies: 4
    Last Post: Jul 09, 2009, 9:37 AM
  4. Replies: 4
    Last Post: May 21, 2009, 12:50 PM
  5. [CLOSED] Loop through tabs
    By reinout.mechant@imprss.be in forum 1.x Legacy Premium Help
    Replies: 9
    Last Post: Mar 27, 2009, 3:59 PM

Posting Permissions