[CLOSED] Load grid with another grid data

Page 2 of 4 FirstFirst 1234 LastLast
  1. #11
    Thanks for your reply,
    Now both code is working.
  2. #12
    Hi,
    Previous example is working fine but I want to do same functionality with grid inside RowExpander plugin.

    In my example ,there are 3 gridpanels.
    1 . targetgrid
    2. sourcegrid
    3. regrid
    regrid placed inside sourcegrid RowExpander plugin.
    I want to copy data from regrid to targetgrid on click on btnAdd.I am unable to write appropriate java script,so I keep btnAdd's .Handler(""),can you please help?

    may be the window is not required ,but I am try to prepare the test case as per original.

    Example View

    @X.ResourceManager()
           
     
                 @(
        Html.X().GridPanel()
        .ID("targetgrid")
                     .Store(
                    Html.X().Store()
                    .DataSource(ViewBag.loadgrid)
                .Model
                 (
                    X.Model()
                    .Fields
                    (
                       X.ModelField().Name("reqid").Type(ModelFieldType.String)
                    )
                  
                 )
                )
                .ColumnModel(
                  
                    Html.X().Column().DataIndex("reqid").Text("Common Name 1").Flex(1)
                    )
                 .SelectionModel(
                X.CheckboxSelectionModel()                
                    .Mode(SelectionMode.Multi)
                   
                )       
        )
    
    
            
             @(
        X.Window()
        .ID("Window1")
        .Height(500)
        .Weight(1200)
        .Hidden(true)
        .Listeners(l => { l.Show.Handler = "App.sourcegrid.getStore().reload();"; })
        .Items
        (
        
         Html.X().GridPanel()
        .ID("sourcegrid")
         .Weight(1200)
        .Layout(LayoutType.Fit)
                .Store(
                    Html.X().Store()
                   
                    
                   .Model
                 (
                    X.Model()
                    .Fields
                    (
                       X.ModelField().Name("reqid").Type(ModelFieldType.String)
                       
                    )
                    
                 )
                 .ServerProxy
    			(
    				X.AjaxProxy()
    				.Url("/Copy_Grid_to_grid/grid2data")
    				.Reader(X.JsonReader().Root("data"))
    			)
                )
                
                .ColumnModel(
                  Html.X().Column().DataIndex("reqid").Text("Common Name 1").Flex(1)
                 
                  )
                 .SelectionModel
                 (
                X.CheckboxSelectionModel()                
                .Mode(SelectionMode.Multi)
                 )
                .Plugins(
                    Html.X().RowExpander()
                    .ID("RowExpander1")
                     .SingleExpand(false)
                         .Listeners(l =>
                        {
                            l.Expand.Handler = @"var rowExpander = this;
            
                                    rowExpander.getComponent(record).getStore().reload({ 
                                        params: {
                                            reqid: record.data.reqid
                                        },
                                        callback: function() {
                                                                
                                            Ext.defer(rowExpander.cmp.doLayout, 1, rowExpander.cmp);
                                        }
                                    });";
                        })
                        .Component
                        (
                                Html.X().GridPanel()
                                .ID("regrid")
                                 .Header(false)
                              .Store(
                                Html.X().Store()
                                .ID("Store1")
                                .AutoLoad(false)
                                .Proxy(Html.X().AjaxProxy()
                                    .Url(Url.Action("rowExpander"))
                                    .Reader(Html.X().JsonReader().Root("data"))
                                    )
     
                                .Model
                                (
                                Html.X().Model()
                                .Fields
                                (
                                Html.X().ModelField().Name("rowexpandertext").Type(ModelFieldType.String)
     
                                )
     
                                )
                                )
                                .ColumnModel
                                (
     
                                Html.X().Column()
                                .DataIndex("rowexpandertext")
                                .Text("rowexpandertext")
     
     
                                )
                                .SelectionModel
                                 (
                                X.CheckboxSelectionModel()                
                                .Mode(SelectionMode.Multi)
                                 )
     
                        )
     
                )
                
                
                        
                 .TopBar
    							(
    								Html.X().Toolbar()
    								.Items
    								(
                                    // Start of Item 3
    								 Html.X().Button()
                                            .ID("btnAdd")
    										.Text("Add record")
    										.Icon(Icon.Add)
    										.Handler("")
                                           
    								)
                                )    
        
        
        
          
                        
        )
        )
    
            @(X.Button().Text("Click to open source grid window")
            .Listeners(l =>
                {
                    l.Click.Handler = "App.Window1.show()";
    
                })
                    
    
            )
    Example Controller


    public class Copy_Grid_to_gridController : Controller
        {
            //
            // GET: /Copy_Grid_to_grid/
    
            public ActionResult Index()
            {
                var l = new List<testGrid>();
                for (int i = 0; i <= 2; i++)
                {
                    var o = new testGrid()
                    {
                        reqid = "GridPanel1-REQID-" + i.ToString(),
                      
                    };
    
                    l.Add(o);
                }
    
                ViewBag.loadgrid = l;
                
                return View();
            }
    
            public ActionResult grid2data()
            {
                var l2 = new List<testGrid>();
                for (int i = 0; i <= 2; i++)
                {
                    var o2 = new testGrid()
                    {
                        reqid = "GridPanel2-REQID-" + i.ToString(),
                      
                    };
    
                    l2.Add(o2);
                }
                return this.Store(l2);
            }
    
            public ActionResult rowExpander(string reqid)
            {
                var l2 = new List<rowexpander>();
                for (int i = 0; i <= 2; i++)
                {
                    var o2 = new rowexpander()
                    {
                        rowexpandertext = "Rowexpander-"+reqid+"-" + i.ToString()
                       
                    };
    
                    l2.Add(o2);
                }
                return this.Store(l2);
            }
    
        }
    
        public class testGrid
        {
            public string reqid { get; set; }
           
    
        }
    
        public class rowexpander
        {
            public string rowexpandertext { get; set; }
           
    
        }
  3. #13
    I want to copy data from regrid to targetgrid on click on btnAdd.I am unable to write appropriate java script,so I keep btnAdd's .Handler(""),can you please help?
    We would be happy to help, but, please, ask a more specific question. I mean breaking the "copy data" task into smaller pieces.
  4. #14
    Hi daniil,goodmorning,
    I think the scenario is clear to you.
    as per previous solution,I try

    Html.X().Button()
                                            .ID("btnAdd")
                                            .Text("Add record")
                                            .Icon(Icon.Add)
                                           .Handler("App.targetgrid.getStore().add(record); this.up('gridpanel').store.removeAt(recordIndex);")
                                            
                                    )
    but this not working .how I get regrid for remove record?
  5. #15
    I think the scenario is clear to you.
    No, it is not. I don't quite understand what exactly you need to copy on the Add click.

    What is the "record" here?
    App.targetgrid.getStore().add(record);
    A Button's Handler doesn't have such the parameter. It is just a shorthand of a Button's Click listener.

    So, what do you mean under "record"?
    Last edited by Daniil; Sep 16, 2014 at 6:18 AM.
  6. #16
    No, it is not. I don't quite understand what exactly you need to copy on the Add click.
    I want to copy selected rows/data from regrid to targetgrid on btnAdd's click.

    how do I get regrid's store on btnAdd's click.
    Last edited by matrixwebtech; Sep 16, 2014 at 7:47 AM.
  7. #17
    Ok, selected rows.

    from regrid
    There might a few of regrid if a few rows are expanded. So, do you need to deal with all or it is supposed to be SingleExpand="true" there?
  8. #18
    In my case
    .SingleExpand(false)

    I read http://forums.ext.net/showthread.php...bject-quot,and try to set
    .SingleExpand(true)
    which may helpfull
    but I need the same for
    .SingleExpand(false)
    because my users expand each section,select some rows/record from grid inside Rowexpander (here regrid) and finally click on "Add record" .
    I request please run my example test case from http://forums.ext.net/showthread.php...ost196641,then I think you will understand the situation.
    Last edited by matrixwebtech; Sep 16, 2014 at 7:52 AM.
  9. #19
    Ok, then you need to iterate all the expanded rows of RowExpander. As far as I can remember, in some thread (started by you) I posted a piece of code how to do that.
  10. #20
    are you talking about http://forums.ext.net/showthread.php?42151 ?
    If yes,I think this is not same.can you please provide me the correct one?
Page 2 of 4 FirstFirst 1234 LastLast

Similar Threads

  1. [CLOSED] Load data to Grid on Documenet ready
    By matrixwebtech in forum 2.x Legacy Premium Help
    Replies: 4
    Last Post: Jun 18, 2014, 8:21 AM
  2. [CLOSED] Load Mask Not displaying on Grid Panel data load
    By WHISHWORKS in forum 2.x Legacy Premium Help
    Replies: 3
    Last Post: Jul 17, 2013, 3:44 PM
  3. Replies: 0
    Last Post: May 16, 2013, 6:46 AM
  4. load grid after draged data
    By krlos02 in forum 1.x Help
    Replies: 1
    Last Post: Sep 01, 2011, 3:28 PM
  5. how to load data to grid panel in page load
    By andylaiyongsing in forum 1.x Help
    Replies: 1
    Last Post: Apr 16, 2010, 10:27 AM

Posting Permissions