[CLOSED] Fill Combobox inside Grid Panel and populate other fields with its selection change event

  1. #1

    [CLOSED] Fill Combobox inside Grid Panel and populate other fields with its selection change event

    @using Ext.Net.MVC
    @using Ext.Net
     
    @{
        ViewBag.Title = "Confirm MessageBox with ButtonsConfig - Ext.NET MVC Examples";
        Layout = null;
        var X = Html.X();
    }
     
     
      
    <script>
     var addPlant = function () {
    
            var r = Ext.create('Plant', {
                //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 });
        };
    
        Ext.onReady(function () {
            // alert('hello world');
            addPlant();
        });
        </script>
         
        </script>
    @X.ResourceManager()
      
         @(
     Html.X().GridPanel().ColSpan(4)
                .ID("gridpanel")
                .Width(600)
                .Height(300)
                .Border(false)
                .Title("Edit Plants")
                .Header(false)
                 // .Layout(LayoutType.Fit)
                .Frame(true)
                .Listeners(l =>
                        {
                            l.ViewReady.Fn = "addPlant";
                            l.ViewReady.Delay = 1;
                        })
                .Store(
                    Html.X().Store().ID("Store1")
                        .Model(
                            Html.X().Model().ID("Model1")
                                .Name("PR")
                                .Fields(
                                    Html.X().ModelField().Name("MaterialID").Type(ModelFieldType.Int),
                                    Html.X().ModelField().Name("UOMCode").Type(ModelFieldType.Int),
                                    Html.X().ModelField().Name("avaiablestock").Type(ModelFieldType.Float),
                                    Html.X().ModelField().Name("requireqty").Type(ModelFieldType.Float),
                                    Html.X().ModelField().Name("UnitRate").Type(ModelFieldType.Float),
                                    Html.X().ModelField().Name("totalvalue").Type(ModelFieldType.Float),
                                    Html.X().ModelField().Name("approvedqty").Type(ModelFieldType.Float),
                                    Html.X().ModelField().Name("approvedunitrate").Type(ModelFieldType.Float),
                                    Html.X().ModelField().Name("approvedtotalvalue").Type(ModelFieldType.Float)
    
                                )
                        )
    
    
                )
    
                .ColumnModel(
    
                         Html.X().Column()
                         .MenuDisabled(true)
                         .Sortable(false)
                        .Text("Material")
                        .DataIndex("MaterialID")
                        .Width(130)
                        .Editor(
                            Html.X().ComboBox()
                            .ID("ddlMaterialID")
                                .TypeAhead(true)
                                .SelectOnTab(true)
                                .ValueField("MaterialID")
                                .DisplayField("MaterialName")
                                .Data(ViewBag.loadddlMaterialID)
                        ),
                        Html.X().Column()
                         .MenuDisabled(true)
                         .Sortable(false)
                        .Text("UOM")
                        .DataIndex("UOMCode")
                        .Width(130)
                        .Editor(
                            Html.X().ComboBox()
                            .ID("ddlUOMCode")
                                .TypeAhead(true)
                                .SelectOnTab(true)
                                .ValueField("UOMCode")
                                .DisplayField("UOMName")
                                .Data(ViewBag.loadddlUOMCode)
                        ),
    
                    Html.X().Column()
                        .Text("Avaiable Stock")
                        .DataIndex("avaiablestock")
                        .Flex(1)
                        .Editor(
                            Html.X().NumberField().AllowBlank(false).Disabled(true)
                        ),
                        Html.X().Column()
                        .Text("Require QTY")
                        .DataIndex("requireqty")
                        .Flex(1)
                        .Editor(
                            Html.X().NumberField().AllowBlank(false).Disabled(true)
                        ),
                        Html.X().Column()
                        .Text("Unit Rate")
                        .DataIndex("unitrate")
                        .Flex(1)
                        .Editor(
                            Html.X().NumberField().AllowBlank(false).Disabled(true)
                        ),
                        Html.X().Column()
                        .Text("Total Value")
                        .DataIndex("totalvalue")
                        .Flex(1)
                        .Editor(
                            Html.X().NumberField().AllowBlank(false).Disabled(true)
                        ),
                        Html.X().Column()
                        .Text("Approved Qty")
                        .DataIndex("approvedqty")
                        .Flex(1)
                        .Editor(
                            Html.X().NumberField().AllowBlank(false).Disabled(true)
                        ),
                         Html.X().Column()
                        .Text("Approved Unit Rate")
                        .DataIndex("approvedunitrate")
                        .Flex(1)
                        .Editor(
                            Html.X().NumberField().AllowBlank(false).Disabled(true)
                        ),
                         Html.X().Column()
                        .Text("Approved Total Value")
                        .DataIndex("approvedtotalvalue")
                        .Flex(1)
                        .Editor(
                            Html.X().NumberField().AllowBlank(false).Disabled(true)
                        ),
    
                    Html.X().DateColumn()
                        .Text("Available")
                        .DataIndex("availability")
                        .Width(95)
                        .Format("dd-MM-yyyy")
                        .Editor(
                            Html.X().DateField()
                                .Format("yyyy-MM-dd")
                                .MinDate(new DateTime(2006, 1, 1))
                                .DisabledDays(new int[] { 0, 6 })
                                .DisabledDaysText("Plants are not available on the weekends")
                        ),
    
                    Html.X().CheckColumn()
                        .Text("Indoor?")
                        .DataIndex("indoor")
                        .StopSelection(false)
                        .Editable(true)
                        .Width(55),
    
                    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 = "this.up('gridpanel').store.removeAt(recordIndex);";
    
                        })
                )
                .SelectionModel(
                    Html.X().CellSelectionModel()
                )
                .Plugins(
                    Html.X().CellEditing().ClicksToEdit(1)
                )
        )
    I generate a view with above code,now I want to populate ddlMaterialID combo box with .Data(ViewBag.loadddlMaterialID) property ,and want o populate other fields of same row on ddlMaterialID selection changed event.please let me know how do i do this.
    Last edited by Daniil; Jul 01, 2014 at 10:38 AM. Reason: [CLOSED]
  2. #2
    Hi @matrixwebtech,

    There is an example with a scenario similar to yours.
    https://examples2.ext.net/#/Form/Com...ombos_In_Grid/
  3. #3
    Quote Originally Posted by Daniil View Post
    Hi @matrixwebtech,

    There is an example with a scenario similar to yours.
    https://examples2.ext.net/#/Form/Com...ombos_In_Grid/
    Thanks for your assistance,Is there any code sample of this functionality for mvc?because this example is help full but some time problem with server side coding,because asp.net and asp.net mvc coding are different.and I am a new user of ext.net so some times I not understand what to be write in server side.
  4. #4
    Unfortunately, there is no such the example in the MVC Examples Explorers, but there are many other examples which might definitely help to understand the syntax.
    http://mvc.ext.net/
  5. #5
    Quote Originally Posted by Daniil View Post
    Unfortunately, there is no such the example in the MVC Examples Explorers, but there are many other examples which might definitely help to understand the syntax.
    http://mvc.ext.net/
    I follow https://examples2.ext.net/#/Form/Com...ombos_In_Grid/ example

    VIEW COD
     @( Html.X().Store()
                        .ID("stormaterialid")
                         
                        .Model(
                            Html.X().Model()
                                .IDProperty("MaterialID")
                                .Fields(
                                  Html.X().ModelField().Name("MaterialID").Type(ModelFieldType.Int),
                                    Html.X().ModelField().Name("MaterialName").Type(ModelFieldType.String)
    
                                 )
    
    
                                )
                                  .ServerProxy(X.AjaxProxy()
                                .Url(Url.Action("Pur_MaterialInformation_Get", "MaterialRequisitionsEntry"))
                                .Reader(X.JsonReader().Root("data"))
                                                      )
    
                                )
    
    
    Html.X().ComboBox()
                            .ID("ddlMaterialID")
                                .TypeAhead(true)
                                .SelectOnTab(true)
                                .ValueField("MaterialID")
                                .DisplayField("MaterialName")
                                .StoreID("stormaterialid")
                                .QueryMode(DataLoadMode.Local)
                                .TriggerAction(TriggerAction.All)
    CONTROLLER CODE

     public StoreResult Pur_MaterialInformation_Get()
            {
                List<tbl_Pur_MaterialInformation> _tbl_Pur_MaterialInformation = new List<tbl_Pur_MaterialInformation>();
                tbl_Pur_MaterialInformation obj_tbl_Pur_MaterialInformation = new tbl_Pur_MaterialInformation();
                _UserSession = (UserSession)Session[AppSession.SessionCurrentUser];
                ERP.Models.PurchaseManagement.MasterManagement.MaterialInformation.MaterialInformation _MaterialInformation = new Models.PurchaseManagement.MasterManagement.MaterialInformation.MaterialInformation();
                obj_tbl_Pur_MaterialInformation.BranchID = _UserSession.BranchID;
                obj_tbl_Pur_MaterialInformation.CompanyID = _UserSession.CompanyID;
                _tbl_Pur_MaterialInformation = _MaterialInformation.Pur_MaterialInformation_Get(obj_tbl_Pur_MaterialInformation);
                return this.Store( _tbl_Pur_MaterialInformation.Cast<object>().ToArray());
            }
    how do I load store on load

    can you please provide me a code sample in mvc razor with a combobox and a text box inside grid,and on combo box selection change text box fill accordingly.
    it will be very helpful for me
    Last edited by matrixwebtech; Jun 26, 2014 at 4:40 PM.
  6. #6
    Quote Originally Posted by matrixwebtech View Post
    can you please provide me a code sample in mvc razor with a combobox and a text box inside grid,and on combo box selection change text box fill accordingly.
    it will be very helpful for me
    According to this description I can provide the following example.

    View
    @model IEnumerable<object>
    
    @{
        var X = Html.X(); 
    }
    
    <!DOCTYPE html>
    <html>
    <head>
        <title>Ext.Net.MVC v2 Example</title>  
    </head>
    <body>
        @X.ResourceManager()
        
        @(X.GridPanel()
            .Store(X.Store()
                .Model(X.Model().Fields("test", "test2"))
                .DataSource(Model)
            )
            .ColumnModel(
                X.Column()
                    .Text("ComboBox")
                    .DataIndex("test")
                    .Editor(X.ComboBox().Items("Item 1", "Item 2", "Item 3")),
                    
               X.Column()
                    .Text("TextField")
                    .DataIndex("test2")
                    .Editor(X.TextField())
            )
            .Plugins(X.CellEditing()
                .Listeners(events =>
                    events.Edit.Handler = @"if (e.field === 'test') {
                                                e.record.set('test2', e.value);
                                            }"
                )
            )
        )
    </body>
    </html>
    Controller
    public ActionResult Index()
    {
        return View(new List<object> 
        { 
            new { test = "Item 1" },
            new { test = "Item 2" },
            new { test = "Item 3" }
        });
    }
  7. #7
    For some reason OP started a new thread regarding this topic and the discussion has continued at the following location:

    http://forums.ext.net/showthread.php...ils-entry-form
    Geoffrey McGill
    Founder

Similar Threads

  1. Replies: 13
    Last Post: Feb 28, 2013, 2:06 PM
  2. Replies: 1
    Last Post: Dec 15, 2012, 6:41 AM
  3. Fill Calendar Panel on combobox selection
    By Rupesh in forum 1.x Help
    Replies: 7
    Last Post: Mar 29, 2012, 2:14 PM
  4. Replies: 1
    Last Post: Nov 08, 2010, 9:31 PM
  5. Replies: 1
    Last Post: Jan 23, 2009, 6:43 AM

Tags for this Thread

Posting Permissions