[CLOSED] Load grid with another grid data

Page 4 of 4 FirstFirst ... 234
  1. #31
    I think it should be possible.

    Your condition looks proper.
    sourcegrid.getStore().getCount() <= 0
    Though, I would probably use "==" instead of "<=".
  2. #32
    Thanks to EXT.Net support team specially @Daniil,for guide us at any point .
  3. #33
    We are always glad to help.

    Please clarify are we done in this thread?
  4. #34
    yes we are done.you can close this .
  5. #35
    I post again here ,by mistake I missed a functionality

    Finally I done bellow code and its working fine

    Example View
    <script type="text/javascript">
           var onClick = function (sourcegrid, targetgrid) {
    
               var values = sourcegrid.getSelectionModel().getSelection();
               sourcegrid.getStore().remove(values)
               var store = targetgrid.getStore();
               store.loadData(values, true)
    
           }
        </script>
    
    
      @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)
                    ,
                    
                    Html.X().ImageCommandColumn()
                    .Sortable(false)
                    .MenuDisabled(true)
                    .Width(30)
                    .Commands(
                    Html.X().ImageCommand()
                    .Icon(Icon.Bin)
                    .ToolTip(t =>
                    {
                        t.Text = "Delete record";
    
                    })
                    .CommandName("delete")
                    )
                    .Listeners(l =>
                    {
    
                        l.Command.Handler = "this.up('gridpanel').store.removeAt(recordIndex);";
    
    
                    })
                    )
                 .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("reqid").Type(ModelFieldType.String)
      
                                )
      
                                )
                                )
                                .ColumnModel
                                (
      
                                Html.X().Column()
                                .DataIndex("reqid")
                                .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)
                                            .Listeners(l =>
                                             {
                                                 l.Click.Handler = @"var records=App.sourcegrid.getStore();
                                                                        
                                                                               records.each(function(record) {
                                                                                   if(App.RowExpander1.getComponent(record))
                                                                                    {
                                                                                  onClick(App.RowExpander1.getComponent(record),#{targetgrid})
                                                                                    }
                                                                               });
                                                                        ";
                                             })
                                            
                                    )
                                )    
         
         
         
           
                         
        )
        )
     
            @(X.Button().Text("Click to open source grid window")
            .Listeners(l =>
                {
                    l.Click.Handler = "App.Window1.show()";
     
                })
                     
     
            )

    Example Controller and Sample Data

    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()
                    {
                        reqid = "Rowexpander-" + reqid + "-" + i.ToString()
    
                    };
    
                    l2.Add(o2);
                }
                return this.Store(l2);
            }
    
        }
    
        public class testGrid
        {
            public string reqid { get; set; }
    
    
        }
    
        public class rowexpander
        {
            public string reqid { get; set; }
    
    
        }
    In this sample I have a delete button in targetgrid,and I need when user a delete any data from targetgrid this record removed and
    placed from where its come.means
    I select a record from first Rowexpander and add to targetgrid and then I delete the record from targetgrid, after delete I need
    the record go to from where its come(first Rowexpander)
  6. #36
    Thank you for sharing the final solution.
  7. #37
    Hi @Daniil I think you missed bellow potion of my post

    In this sample I have a delete button in targetgrid,and I need when user a delete any data from targetgrid this record removed and
    placed from where its come.means
    I select a record from first Rowexpander and add to targetgrid and then I delete the record from targetgrid, after delete I need
    the record go to from where its come(first Rowexpander)
    http://forums.ext.net/showthread.php...l=1#post197381
  8. #38
    Ok, you've described the requirement in details. Could you, please, clarify what exactly problem you are facing in implementing that?
  9. #39
    I don't know what code I have to write to do this,

    Html.X().ImageCommandColumn()
                    .Commands(
                    Html.X().ImageCommand()
                    .Icon(Icon.Bin)
                     .CommandName("delete")
                    )
                    .Listeners(l =>
                    {
                         l.Command.Handler = "this.up('gridpanel').store.removeAt(recordIndex);";
     
                    })
    currently this code remove record from targetgrid,I want the deleted record placed at in RowExpander from where I previously copied that record.
  10. #40
    from where I previously copied that record
    You should save somewhere the place where you copied it from. I would consider an additional ModelField for that.
Page 4 of 4 FirstFirst ... 234

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