[CLOSED] Load grid with another grid data

Page 1 of 4 123 ... LastLast
  1. #1

    [CLOSED] Load grid with another grid data

    I have 2 gridpanels GridPanel1 and GridPanel2

    In GridPanel2 I have an

    ImageCommandColumn
    I am trying to fill GridPanel1 with the data delete from GridPanel2,
    Bellow is my code

    Html.X().ImageCommandColumn()
                        .Width(30)
                        .Commands(
                            Html.X().ImageCommand()
                                .Icon(Icon.Decline)
                                .ToolTip(t =>
                                {
                                    t.Text = "Delete plant";
                                })
                                .CommandName("delete")
                        )
                        .Listeners(l => {
                            l.Command.Handler = "App.GridPanel1.getStore().loadData((App.GridPanel2.getStore().getAt(recordIndex)),true);this.up('gridpanel').store.removeAt(recordIndex);";
                        })
    Last edited by Daniil; Sep 26, 2014 at 12:18 PM. Reason: [CLOSED]
  2. #2
    Hi @matrixwebtech,

    I would try this .
    l.Command.Handler = "App.GridPanel1.getStore().add(record); this.grid.geStore().remove(record);";
  3. #3
    Goodmorning Daniil,Thanks for reply

    I use your code ,with this data added to GridPanel1,but not removed from GridPanel2.

    l.Command.Handler = "App.GridPanel1.getStore().add(record); this.grid.geStore().remove(record);";
    but if I use bellow code,both working fine ,data added to GridPanel1,and removed from GridPanel2.

    l.Command.Handler = "App.GridPanel1.getStore().add(record); this.up('gridpanel').store.removeAt(recordIndex);";
    any comment?
  4. #4
    Please provide a full test case.
  5. #5
    VIEW
    @{
        var X = Html.X();
        Layout = null;
    }
     
    <!DOCTYPE html>
     
    <html>
    <head>
        <meta name="viewport" content="width=device-width" />
        <title>Index</title>
       <script type="text/javascript">
           var onClick = function () {
               
               var values = App.GridPanel1.getSelectionModel().getSelection();
               App.GridPanel1.getStore().remove(values)
               var store = App.GridPanel2.getStore();
               store.loadData(values,true)
               console.log(values);
               console.log(store);
           }
        </script>
    </head>
    <body>
        <div>
            @X.ResourceManager()
           
                 @(
        Html.X().GridPanel()
        .ID("GridPanel1")
        .ForceFit(true)
        .Title("GridPanel1")
        .AutoScroll(true)
        .Scroll(ScrollMode.Both)
                  .Store(
                    Html.X().Store()
                    .DataSource(ViewBag.loadgrid)
                    
                          .Model
                 (
                    X.Model()
                    .Fields
                    (
                       X.ModelField().Name("reqid").Type(ModelFieldType.String),
                        X.ModelField().Name("matid").Type(ModelFieldType.String),
                         X.ModelField().Name("quotid").Type(ModelFieldType.String)
                          
                       
                       
                         
                    )
                  
                 )
                )
                .ColumnModel(
                  
                    Html.X().Column().DataIndex("reqid").Text("Common Name 1").Flex(1),
                     Html.X().Column().DataIndex("matid").Text("Common Name 2").Flex(1),
                      Html.X().Column().DataIndex("quotid").Text("Common Name 3").Flex(1)
                          
                   
                    
                    
                )
                 .SelectionModel(
                X.CheckboxSelectionModel()                
                    .Mode(SelectionMode.Multi)
                   
                )
                        
                       
                        .BottomBar(
                            Html.X().PagingToolbar()
                               
                        )
        )
    
    
            @(
        Html.X().GridPanel()
        .ID("GridPanel2")
         .Title("GridPanel2")
                .Store(
                    Html.X().Store()
                    .DataSource(ViewBag.loadgrid2)
                    
                   .Model
                 (
                    X.Model()
                    .Fields
                    (
                       X.ModelField().Name("reqid").Type(ModelFieldType.String),
                        X.ModelField().Name("matid").Type(ModelFieldType.String),
                         X.ModelField().Name("quotid").Type(ModelFieldType.String)
                          
                       
                       
                         
                    )
                  
                 )
                )
                .ColumnModel(
                  
                    Html.X().Column().DataIndex("reqid").Text("Common Name 1").Flex(1),
                     Html.X().Column().DataIndex("matid").Text("Common Name 2").Flex(1),
                      Html.X().Column().DataIndex("quotid").Text("Common Name 3").Flex(1),
                      
                      Html.X().ImageCommandColumn()
                        .Width(30)
                        .Commands(
                            Html.X().ImageCommand()
                                .Icon(Icon.Decline)
                                .ToolTip(t =>
                                {
                                    t.Text = "Delete plant";
                                })
                                .CommandName("delete")
                        )
                        .Listeners(l => {
    
                            //l.Command.Handler = "App.GridPanel1.getStore().add(record); this.grid.geStore().remove(record);";
                           l.Command.Handler = "App.GridPanel1.getStore().add(record); this.up('gridpanel').store.removeAt(recordIndex);";
                            
                        })
                     
                    
                )
                 .SelectionModel(
                X.CheckboxSelectionModel()                
                    .Mode(SelectionMode.Multi)
                   
                )
                        
                       
                        .BottomBar(
                            Html.X().PagingToolbar()
                               
                        )
        )
    
    
            @(X.Button().Text("click")
            .Listeners(l =>
                {
                    l.Click.Handler = "onClick()";
    
                })
                    
    
            )
    
    
        </div>
    </body>
    </html>
    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(),
                        matid = "GridPanel1-MATID-" + i.ToString(),
                        quotid = "GridPanel1-QUOTID-" + i.ToString(),
                    };
    
                    l.Add(o);
                }
    
                ViewBag.loadgrid = l;
                var l2 = new List<testGrid>();
                for (int i = 0; i <= 2; i++)
                {
                    var o2 = new testGrid()
                    {
                        reqid = "GridPanel2-REQID-" + i.ToString(),
                        matid = "GridPanel2-MATID-" + i.ToString(),
                        quotid = "GridPanel2-QUOTID-" + i.ToString(),
                    };
    
                    l2.Add(o2);
                }
                ViewBag.loadgrid2 = l2;
                return View();
            }
    
        }
    
        public class testGrid
        {
            public string reqid { get; set; }
            public string matid { get; set; }
            public string quotid { get; set; }
    
        }
    There are 2 listener Handler in GridPanel2 ,commented function not working.
    Select some record from Gridpanel1 and click on button,then remove data from Gridpanel2
  6. #6
    Please clarify do you see any JavaScript errors?
  7. #7
    With

    l.Command.Handler = "App.GridPanel1.getStore().add(record); this.grid.geStore().remove(record);";
    bellow javascript error occurred

    TypeError: this.grid.geStore is not a function
    ...dPanel1.getStore().add(record); this.grid.geStore().remove(record);}}}}]},"selMo...
  8. #8
    Yes, I have the same. I think there is a mistype.
  9. #9
    so what I do,will I go with

    l.Command.Handler = "App.GridPanel1.getStore().add(record); this.up('gridpanel').store.removeAt(recordIndex);";
  10. #10
    Yes, you can.

    Or change "geStore" to "getStore" in my code. As I said, I've just mistyped.
Page 1 of 4 123 ... 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