[CLOSED] Master Details entry form

Page 1 of 2 12 LastLast
  1. #1

    [CLOSED] Master Details entry form

    Hi
    I need some code help .I stuck into this from last 15 days.I attach a screen shot ,please look into this and please provide me sample code .
    I stuck into view code.

    CONTROLLER CODE

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Web;
    using System.Web.Mvc;
    
    namespace ERP_test.Controllers
    {
        public class masterdetailsController : Controller
        {
            //
            // GET: /masterdetails/
    
            public ActionResult Index()
            {
                
                ViewBag.loadcategory = category.categoryGetAll();
                return View();
            }
    
        }
    }
    
    
    
    public class material
    {
        public int materialID { get; set; }
        public string code { get; set; }
        public string materialIDName { get; set; }
        public int unitid { get; set; }
        public int categoryid { get; set; }
    
        public static List<material> materialGetAll()
        {
            return new List<material>
                           {
                               new material {materialID = 1,code="m001", materialIDName = "material A",unitid=1,categoryid=1},
                               new material {materialID = 2, code="m002",materialIDName = "material B",unitid=1,categoryid=1},
                               new material {materialID = 3, code="m003",materialIDName = "material C",unitid=2,categoryid=2}
                           };
        }
    }
    
    public class unit
    {
        public int unitid { get; set; }
        public string unitName { get; set; }
    
    
        public static List<unit> unitGetAll()
        {
            return new List<unit>
                           {
                               new unit { unitid=1,unitName = "unit A"},
                               new unit { unitid=2,unitName = "unit B"},
                               
                           };
        }
    }
    
    public class category
    {
        public int categoryid { get; set; }
        public string categoryName { get; set; }
    
    
        public static List<category> categoryGetAll()
        {
            return new List<category>
                           {
                               new category { categoryid=1,categoryName = "category A"},
                               new category { categoryid=2,categoryName = "category B"},
                               
                           };
        }
    }
    Attached Thumbnails Click image for larger version. 

Name:	functionalityrequired.png 
Views:	331 
Size:	29.8 KB 
ID:	13121  
    Last edited by Daniil; Jul 08, 2014 at 5:26 AM. Reason: [CLOSED]
  2. #2
    Can you explain further what you are trying to accomplish? The text on your image is difficult to read.

    As well, the code sample you provided does not appear to reproduce the scenario. I was unable to test.
    Geoffrey McGill
    Founder
  3. #3
    Thankx for reply

    I need a grid with with 7 columns

    Column FieldType
    category Combobox
    Poduct Combobox
    Unit Combobox
    unitprice Numericfield
    quantity Numericfield
    expected price Numericfield
    delete


    for first time when page load the first row is load by default.expect category combo other fields are blank.after select a category the product combo fill,
    from product combo after selecting a product other fields are (Unit ,unitprice) fill according selected product.then i enter quantity(by default quantity is 0)
    if quantity>0 then expected price=quantity*unitprice.each time when i change quantity i need to calculate sum of all expected price and need to show in total amount .when i delete a row then ( total amount =totalamount-expected price of deleted row)

    Edit mode-when page is load the grid is load with existing data,new record can be inserted.but only quantity can be change for existing data.

    please tally the image with my writeup ,I think this will help you to understand what I trying to accomplish.I attach a new screen shot.
    Attached Thumbnails Click image for larger version. 

Name:	functionalityrequired.png 
Views:	341 
Size:	28.8 KB 
ID:	13141  
    Last edited by geoffrey.mcgill; Jun 29, 2014 at 1:10 AM.
  4. #4
    I do a design like this

    VIEW CODE

    @using Ext.Net
    @using Ext.Net.MVC
    
     
    @{
        var X = Html.X(); 
    }
     
    <!DOCTYPE html>
    <html>
    <head>
        <title>Ext.Net.MVC v2 Example</title>  
        <script>
            var addPlant = function () {
    
                var r = Ext.create('pr', {
                    //common: 'New Plant 1',
                    //light: 'Mostly Shady',
                    //price: 0,
                    //availability: Ext.Date.clearTime(new Date()),
                    //indoor: false
    
    
                }),
                     grid = App.gridpanel;
    
                grid.store.insert(0, r);
                grid.editingPlugin.startEditByPosition({ row: 0, column: 0 });
            };
            var departmentRenderer = function (value) {
                
                var r = App.scategory.getById(value);
    
                if (Ext.isEmpty(r)) {
                    return "";
                }
    
                return r.data.Name;
            };
           
        </script>
    </head>
    <body>
        @X.ResourceManager()
         
        @(X.Store(
                X.Store()
                    .Data(ViewBag.loadcategory)
                        .ID("scategory")
                        .Model(
                            X.Model()
    
                                .Fields(
                                    Html.X().ModelField().Name("categoryid").Type(ModelFieldType.Int),
                                    Html.X().ModelField().Name("categoryName").Type(ModelFieldType.String)
    
                                        )
                                )
                                
                                
    
                            )
                            
                            )
    
    
        @(X.GridPanel()
            .ID("gridpanel")
                            .Listeners(l =>
                                        {
                                            l.ViewReady.Fn = "addPlant";
                                            l.ViewReady.Delay = 1;
                                        })
            .Store(Html.X().Store()
                .Model(Html.X().Model()
                    .Name("pr")
                    //.IDProperty("ID")
                    .Fields(
                        new ModelField("griddatamaterialID", ModelFieldType.Int),
                        new ModelField("griddatacategoryid", ModelFieldType.Int),
                        new ModelField("griddataunitid", ModelFieldType.Int),
                        new ModelField("griddataquantity", ModelFieldType.Int),
                        new ModelField("griddataexpectedamount", ModelFieldType.Int)
                    )
                )
               // .DataSource(ViewBag.loadgrid)
                        
              
            )
            
            .ColumnModel(
                X.Column()
                    .Text("categoryName")
                    .DataIndex("griddatacategoryid")
                  
                    //.Renderer("departmentRenderer")
                    .Editor(
                    X.ComboBox()
                    
                    .DataIndex("categoryid")
                    .StoreID("scategory")
                    .TypeAhead(true)
                    .SelectOnTab(true)
                    .ValueField("categoryid")
                    .DisplayField("categoryName")
                    
                    ),
                    
                     
                X.Column()
                    .Text("material")
                   .DataIndex("griddatamaterialID")
                    .Editor(
                    X.ComboBox()
                    .DataIndex("materialID")
                    .TypeAhead(true)
                    .SelectOnTab(true)
                    .ValueField("materialID")
                    .DisplayField("materialIDName")
                    .Data( ViewBag.loadcategory)
                    ),
                        X.Column()
                    .Text("unit")
                   .DataIndex("griddataunitid")
                    .Editor(
                    X.ComboBox()
                    .DataIndex("unitid")
                    .TypeAhead(true)
                    .SelectOnTab(true)
                    .ValueField("unitid")
                    .DisplayField("unitName")
                    .Data( ViewBag.loadcategory)
                    ),
               X.Column()
                    .Text("Unit Price")
                   
                    .Editor(
                    X.TextField()),
                    
                     X.Column()
                     .Text("Quantity")
                     .DataIndex("griddataquantity")
                   .Editor(X.TextField()),
                   X.Column()
                   .DataIndex("griddataexpectedamount")
                     .Text("Expected Price")
                   .Editor(X.TextField())
            )
            .Plugins(X.CellEditing()
    //            .Listeners(events =>
    //                events.Edit.Handler = @"if (e.field === 'test') {
    //                                            e.record.set('test2', e.value);
    //                                        }"
    //            )
            )
                )
    </body>
    </html>


    CONROLLER CODE

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Web;
    using System.Web.Mvc;
    
    namespace ERP_test.Controllers
    {
        public class masterdetailsController : Controller
        {
            //
            // GET: /masterdetails/
    
            public ActionResult Index()
            {
                //ViewBag.loadcategory = category.categoryGetAll().Cast<object>().ToArray();
                ViewBag.loadcategory = category.categoryGetAll();
               
                //ViewBag.loadgrid = griddata.griddataGetAll();
                return View();
            }
    
        }
    }
    public class griddata
    {
        public int griddatamaterialID { get; set; }
        public int griddatacategoryid { get; set; }
        public int griddataunitid { get; set; }
        public int griddataquantity { get; set; }
        public int griddataexpectedamount { get; set; }
    
        public static List<griddata> griddataGetAll()
        {
            return new List<griddata>
                           {
                              new griddata {griddatamaterialID = 0,griddatacategoryid=0,griddataunitid=0, griddataquantity = 0,griddataexpectedamount=0},
                               
                           };
        }
    }
    
    
    public class material
    {
        public int materialID { get; set; }
        public string code { get; set; }
        public string materialIDName { get; set; }
        public int unitid { get; set; }
        public int categoryid { get; set; }
    
        public static List<material> materialGetAll()
        {
            return new List<material>
                           {
                               new material {materialID = 1,code="m001", materialIDName = "material A",unitid=1,categoryid=1},
                               new material {materialID = 2, code="m002",materialIDName = "material B",unitid=1,categoryid=1},
                               new material {materialID = 3, code="m003",materialIDName = "material C",unitid=2,categoryid=2}
                           };
        }
    }
    
    public class unit
    {
        public int unitid { get; set; }
        public string unitName { get; set; }
    
    
        public static List<unit> unitGetAll()
        {
            return new List<unit>
                           {
                               new unit { unitid=1,unitName = "unit A"},
                               new unit { unitid=2,unitName = "unit B"},
                               
                           };
        }
    }
    
    public class category
    {
        public int categoryid { get; set; }
        public string categoryName { get; set; }
    
    
        public static List<category> categoryGetAll()
        {
            return new List<category>
                           {
                               new category { categoryid=1,categoryName = "category A"},
                               new category { categoryid=2,categoryName = "category B"},
                               
                           };
        }
    }
    I need on first time all category load to category combo,after select a category material combo will fill.then after selecting material unit price and unit will fill.then i put quantity .then expected price calculate (UnitPrice*Quantity) and summery expected price will be show.I will not found any example of this scenario,so please help me and provide me some code sample to complete this.
    Last edited by geoffrey.mcgill; Jun 29, 2014 at 6:50 PM.
  5. #5
    Quote Originally Posted by matrixwebtech View Post
    I need on first time all category load to category combo,after select a category material combo will fill...
    I think we are already discussing this problem here:
    http://forums.ext.net/showthread.php?38231

    You have left my last post unanswered. If you answer something, we can continue the discussion.

    Or you just mixed up the threads? If so, please post it in the initial thread and I'll clean this thread.
  6. #6
    Hi daniil
    thanks for your reply,and apologize for my mistake. I am new to ext.net so some times I can't catch codes provided by you.please continue discussion here.

    I think you will understand what I want to do.so please help me and provide some sample code.

    I am confused with all things,so I will do one by one

    VIEW CODE

    @using Ext.Net
    @using Ext.Net.MVC
    
     
    @{
        var X = Html.X(); 
    }
     
    <!DOCTYPE html>
    <html>
    <head>
        <title>Ext.Net.MVC v2 Example</title>  
        <script>
            var addPlant = function () {
    
                var r = Ext.create('pr', {
                    //common: 'New Plant 1',
                    //light: 'Mostly Shady',
                    //price: 0,
                    //availability: Ext.Date.clearTime(new Date()),
                    //indoor: false
    
    
                }),
                     grid = App.gridpanel;
    
                grid.store.insert(0, r);
                grid.editingPlugin.startEditByPosition({ row: 0, column: 0 });
            };
            var departmentRenderer = function (value) {
                
                var r = App.scategory.getById(value);
               
                if (Ext.isEmpty(r)) {
                    return "";
                }
    
                return r.data.Name;
            };
           
        </script>
    </head>
    <body>
        @X.ResourceManager()
         
        @(X.Store(
                X.Store()
                    .Data(ViewBag.loadcategory)
                        .ID("scategory")
                        .Model(
                            X.Model()
    
                                .Fields(
                                    Html.X().ModelField().Name("categoryid").Type(ModelFieldType.Int),
                                    Html.X().ModelField().Name("categoryName").Type(ModelFieldType.String)
    
                                        )
                                )
                          )
                  )
    
    
        @(X.GridPanel()
            .ID("gridpanel")
                .Listeners(l =>
                            {
                                l.ViewReady.Fn = "addPlant";
                                l.ViewReady.Delay = 1;
                            })
            .Store(Html.X().Store()
                .Model(Html.X().Model()
                    .Name("pr")
                    //.IDProperty("ID")
                    .Fields(
                        new ModelField("griddatamaterialID", ModelFieldType.Int),
                        new ModelField("griddatacategoryid", ModelFieldType.Int),
                        new ModelField("griddataunitid", ModelFieldType.Int),
                        new ModelField("griddataquantity", ModelFieldType.Int),
                        new ModelField("griddataexpectedamount", ModelFieldType.Int)
                    )
                )
                //.DataSource(ViewBag.loadgrid)
                        
              
            )
            
            .ColumnModel(
                X.Column()
                    .Text("categoryName")
                    .DataIndex("griddatacategoryid")
                  
                    //.Renderer("departmentRenderer")
                    .Editor(
                    X.ComboBox()
                    .QueryMode(DataLoadMode.Local)
                    //.DataIndex("categoryid")
                    .StoreID("scategory")
                    .TypeAhead(true)
                    .SelectOnTab(true)
                    .ValueField("categoryid")
                    .DisplayField("categoryName")
                    
                    
                    ),
                    
                     
                X.Column()
                    .Text("material")
                   .DataIndex("griddatamaterialID")
                    .Editor(
                    X.ComboBox()
                    .DataIndex("materialID")
                    .TypeAhead(true)
                    .SelectOnTab(true)
                    .ValueField("materialID")
                    .DisplayField("materialIDName")
                    .Data( ViewBag.loadcategory)
                    ),
                        X.Column()
                    .Text("unit")
                   .DataIndex("griddataunitid")
                    .Editor(
                    X.ComboBox()
                    .DataIndex("unitid")
                    .TypeAhead(true)
                    .SelectOnTab(true)
                    .ValueField("unitid")
                    .DisplayField("unitName")
                    .Data( ViewBag.loadcategory)
                    ),
               X.Column()
                    .Text("Unit Price")
                   
                    .Editor(
                    X.TextField()),
                    
                     X.Column()
                     .Text("Quantity")
                     .DataIndex("griddataquantity")
                   .Editor(X.TextField()),
                   X.Column()
                   .DataIndex("griddataexpectedamount")
                     .Text("Expected Price")
                   .Editor(X.TextField())
            )
            .Plugins(X.CellEditing()
                        .Listeners(events =>
                            events.Edit.Handler = @"if (e.field === 'griddatacategoryid') {
                                                               
                                                e.record.set('test2', e.value);
                                            }"
                        )
            )
                )
    </body>
    </html>
    CONTROLLER CODE

     public ActionResult Index()
            {
                ViewBag.loadcategory = category.categoryGetAll().Cast<object>().ToArray();
                
                //ViewBag.loadgrid = griddata.griddataGetAll();
                return View();
            }
    
    public class category
    {
        public int categoryid { get; set; }
        public string categoryName { get; set; }
    
    
        public static List<category> categoryGetAll()
        {
            return new List<category>
                           {
                               new category { categoryid=1,categoryName = "category A"},
                               new category { categoryid=2,categoryName = "category B"},
                               
                           };
        }
    }
    1>I fill category combo with this.but the combo showing valuefiled not displayfield.
    2>After that I want to fetch all product from data base by select category.
    3>After product load ,when a product select fetch unit and unit price of this pitifuller product.
    4>after fill unit price and user input quantity,then expected price field id is calculate.
    5>summarize all expected price .
    6>after that there are a save button,on click on save all (row column wise)data will be inserted in data base.

    please help me to accomplish this job in simple way.
    Last edited by matrixwebtech; Jun 30, 2014 at 6:49 PM.
  7. #7
    Quote Originally Posted by matrixwebtech View Post
    1>I fill category combo with this.but the combo showing valuefiled not displayfield.
    You should use a Column's Renderer. Please see the Department Column in this example:
    https://examples2.ext.net/#/GridPane...Field_Mapping/

    Please keep one issue per thread. After resolving this one, please start a new thread for the next (the only one) issue.
  8. #8
    Hi
    daniil
    Thankx for reply


    As per Editor Field Mapping example I write bellow code

    MODEL
    using System;
    using System.Collections;
    using System.Collections.Generic;
    
    namespace ERP_test.Controllers
    {
    
        public class category
        {
            public int cid { get; set; }
            public string cn { get; set; }
    
    
            public static List<category> categoryGetAll()
            {
                return new List<category>
                           {
                               new category { cid=1,cn= "category A"},
                               new category { cid=2,cn= "category B"},
                               new category { cid=3,cn= "category C"},
                               
                           };
            }
        }
        public class Department
        {
            public int ID { get; set; }
            public string Name { get; set; }
    
            public static List<Department> GetAll()
            {
                return new List<Department>
                           {
                               new Department {ID = 1, Name = "Department A"},
                               new Department {ID = 2, Name = "Department B"},
                               new Department {ID = 3, Name = "Department C"}
                           };
            }
        }
    
    }

    WORKING CODE


    @using Ext.Net
    @using Ext.Net.MVC
    
     
    @{
        var X = Html.X(); 
    }
     
    
        <script>
            var addPlant = function () {
    
                var r = Ext.create('pr', {
                    //common: 'New Plant 1',
                    //light: 'Mostly Shady',
                    //price: 0,
                    //availability: Ext.Date.clearTime(new Date()),
                    //indoor: false
    
    
                }),
                     grid = App.gridpanel;
    
                grid.store.insert(0, r);
                grid.editingPlugin.startEditByPosition({ row: 0, column: 0 });
            };
    
    
            var departmentRenderer = function (value) {
               // alert(value)
                var r = App.StoreCombo1.getById(value);
                //alert(r)
                if (Ext.isEmpty(r)) {
                    //alert('Here 1')
                    return "";
                }
                //alert(r.data.Name)
                return r.data.Name;
            };
           
        </script>
    
         
         @Html.X().ResourceManager()
        @(Html.X().Store()
            .ID("StoreCombo1")
            .Model(Html.X().Model()
                .IDProperty("ID")
                
               .Fields(
                    Html.X().ModelField().Name("ID").Type(ModelFieldType.Int),
                    Html.X().ModelField().Name("Name").Type(ModelFieldType.String)
            )
            )
            .DataSource(ViewBag.loadcategory)
        )
    
        @(Html.X().GridPanel()
        .ID("gridpanel")
            .Title("List")
                    .Listeners(l =>
                            {
                                l.ViewReady.Fn = "addPlant";
                                l.ViewReady.Delay = 1;
                            })
            .Icon(Icon.Application)
            .Store(Html.X().Store()
                .Model(Html.X().Model()
                 
                    .Name("pr")
                    
                    
                )
               
            )
            .ColumnModel(
            
                Html.X().Column()
                    
                    .DataIndex("")
                  
                    .Renderer("departmentRenderer")
                    .Editor
                    (
                        Html.X().ComboBox()
                        .QueryMode(DataLoadMode.Local)
                        .Editable(false)
                        .StoreID("StoreCombo1")
                        .DisplayField("Name")
                        .ValueField("ID")
                    )
            )
            .Plugins(Html.X().CellEditing())
        )
    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Web;
    using System.Web.Mvc;
    using Ext.Net;
    using Ext.Net.MVC;
    namespace ERP_test.Controllers
    {
        public class masterdetailsController : Controller
        {
            //
            // GET: /masterdetails/
    
            public ActionResult Index()
            {
                ViewBag.loadcategory = Department.GetAll();
                
                
                return View();
            }
    
        }
    }

    CODE NOT WORKING


    @using Ext.Net
    @using Ext.Net.MVC
    
    @{
        ViewBag.Title = "Editor Field Mapping - Ext.NET MVC Examples";
       
    }
    
    
        <script>
            var addPlant = function () {
    
                var r = Ext.create('pr', {
                    //common: 'New Plant 1',
                    //light: 'Mostly Shady',
                    //price: 0,
                    //availability: Ext.Date.clearTime(new Date()),
                    //indoor: false
    
    
                }),
                     grid = App.gridpanel;
    
                grid.store.insert(0, r);
                grid.editingPlugin.startEditByPosition({ row: 0, column: 0 });
            };
    
            var departmentRenderer = function (value) {
               // alert(value)
                var r = App.StoreCombo.getById(value);
               //alert(r)
               if (Ext.isEmpty(r)) {
                  // alert('Here 1')
                    return "";
                }
               //alert(r.data.Name)
                return r.data.Name;
            };
        </script>
    
    
    @Html.X().ResourceManager()
    
    @(Html.X().Store()
            .ID("StoreCombo")
            .Model(Html.X().Model()
                .IDProperty("cid")
    
               .Fields(
                            Html.X().ModelField().Name("cid").Type(ModelFieldType.Int),
                            Html.X().ModelField().Name("cn").Type(ModelFieldType.String)
                    )
            )
            .DataSource(ViewBag.model1)
        )
    
    @(Html.X().GridPanel()
        .ID("gridpanel")
            .Title("List")
                    .Listeners(l =>
                            {
                                l.ViewReady.Fn = "addPlant";
                                l.ViewReady.Delay = 1;
                            })
            .Icon(Icon.Application)
            .Store(Html.X().Store()
                .Model(Html.X().Model()
            // .IDProperty("ID")
                    .Name("pr")
    
    
                )
    
            )
            .ColumnModel(
    
                Html.X().Column()
    
                  .DataIndex("")
                  .Renderer("departmentRenderer")
                    .Editor
                    (
                        Html.X().ComboBox()
                        .QueryMode(DataLoadMode.Local)
                        .Editable(false)
                        .StoreID("StoreCombo")
                        .DisplayField("cn")
                        .ValueField("cid")
                    )
            )
            .Plugins(Html.X().CellEditing())
        )
    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Web;
    using System.Web.Mvc;
    
    namespace ERP_test.Controllers
    {
        public class Editor_Field_MappingController : Controller
        {
            public ActionResult Index()
            {
               
                ViewBag.model1 = category.categoryGetAll();
                return View();
              
            }
        }
    }
    I think these tow sample code is same only name and variables are different,but one code set is running another is not.I am puzzled.please check and let me know what I doing wrong.
    Last edited by geoffrey.mcgill; Jul 02, 2014 at 11:56 AM.
  9. #9
    In the non-working code you should replace
    return r.data.Name;
    with
    return r.data.cn;
    There is no "Name" ModelField in the Model's Fields of the StoreCombo:
    Html.X().ModelField().Name("cid").Type(ModelFieldType.Int),
    Html.X().ModelField().Name("cn").Type(ModelFieldType.String)
  10. #10
    Thank you very much
    as per http://forums.ext.net/showthread.php...example-in-MVC I take update from svn.
    If i not bind all column with combo,may be some fields are text box,and follow Linked-Combos-In-Grid-example-in-MVC coding is that help full?
    Last edited by geoffrey.mcgill; Jul 02, 2014 at 7:57 PM.
Page 1 of 2 12 LastLast

Similar Threads

  1. Replies: 0
    Last Post: Jul 15, 2013, 6:39 PM
  2. [CLOSED] Template master details
    By bossun in forum 2.x Legacy Premium Help
    Replies: 1
    Last Post: Jan 27, 2013, 7:25 PM
  3. Replies: 0
    Last Post: Feb 10, 2012, 11:44 PM
  4. Replies: 0
    Last Post: Jun 07, 2010, 8:52 PM
  5. Example GridPanel with Form Details
    By Diabolicus in forum 1.x Help
    Replies: 1
    Last Post: Oct 21, 2008, 10:07 AM

Posting Permissions