[CLOSED] Razor- Grid Panel Editor Combobox

Page 2 of 4 FirstFirst 1234 LastLast
  1. #11
    I would try like this.

    Example View
    <!DOCTYPE html>
    
    <html>
    <head>
        <title>Ext.Net.MVC v2 Example</title>    
    </head>
    <body>
        @Html.X().ResourceManager()
    
        @(Html.X().GridPanel()
            .Height(200)
            .Store(Html.X().Store()
                .Model(Html.X().Model()
                    .Fields(Html.X().ModelField().Name("test"))
                )
                .Proxy(Html.X().AjaxProxy()
                    .Url(Url.Action("GetDataForGridPanel"))
                    .Reader(Html.X().JsonReader().Root("data"))
                )
            )
            .ColumnModel(Html.X().Column()
                .Text("Test")
                .DataIndex("test")
                .Editor(Html.X().ComboBox()
                    .DisplayField("text")
                    .ValueField("value")
                    .Store(Html.X().Store()
                        .AutoLoad(false)
                        .Model(Html.X().Model()
                            .Fields("value", "text")
                        )
                        .Proxy(Html.X().AjaxProxy()
                            .Reader(Html.X().JsonReader().Root("data"))
                            .CustomConfig(cc => cc.Add(new { rawUrl = Url.Action("GetDataForComboBox") }))
                        )
                    )
                )
            )
            .Plugins(Html.X().CellEditing()
                .Listeners(events =>
                {
                    events.BeforeEdit.Handler = @"var field = this.getEditor(e.record, e.column).field; 
                                                      proxy = field.getStore().proxy;
    
                                                  delete field.lastQuery;
                                                  proxy.url = proxy.rawUrl + '/' + e.value;";
                })
            )
        )
    </body>
    </html>
  2. #12
    Hi

    I see what you are getting at but after intagrating this into my code the best is gives is the value of the current field not the one to the left. Also there are many comboboxes on the panel so this code would get in the way of them all which is not desired.

    I looked back at one of my first posts and adjusting your code as follows gets me what I want with the listener. But now the listener gets in the way of my other drop downs. Is there a better way to get the value or at lest have it only effect one of the combos?

    
    proxy.url = proxy.rawUrl + '/' + #{DetailPanel}.getRowsValues({selectedOnly:true})[0].CounterpartyId;";
    Last edited by OriCoder; Jan 18, 2013 at 5:50 PM.
  3. #13
    Quote Originally Posted by OriCoder View Post
    I see what you are getting at but after intagrating this into my code the best is gives is the value of the current field not the one to the left. Also there are many comboboxes on the panel so this code would get in the way of them all which is not desired.
    If you need values of other record's fields, then you could use something like this
    e.record.get("CounterpartyId")
    instead of "e.value".

    Quote Originally Posted by OriCoder View Post
    I looked back at one of my first posts and adjusting your code as follows gets me what I want with the listener. But now the listener gets in the way of my other drop downs. Is there a better way to get the value or at lest have it only effect one of the combos?

    
    proxy.url = proxy.rawUrl + '/' + #{DetailPanel}.getRowsValues({selectedOnly:true})[0].CounterpartyId;";
    The requirement is not clear for me. Could you, please, provide some runnable and simplified example which would demonstrate the problem/requirement?

    There is also a possibility to just load ComboBox items within a BeforeEdit listener.
    combo.getStore().load({ /*options */ });
  4. #14
    Thanks Daniil, I wont get a look at the app till later tonight. really just need for the listener code to cut in on a specified combo box rather than them all. I'll see how far I get and post back an example
  5. #15
    Ok, will wait an example.

    For a specified ComboBox... I think the ComboBox's BeforeQuery event might be helpful here.
    http://docs.sencha.com/ext-js/4-1/#!...nt-beforequery
  6. #16
    Still looking at this and the more I try before query etc, all seams to be getting very complex java script for what should be somthing very simple. Should I not be trying to do somthing like below.. simlar to the following post although I know that this is a direct event and I have these working.

    http://forums.ext.net/showthread.php...m-DirectEvents


    I know i've said it before but how hard can it be just to pick up the value from the cell on the left and pass it as an extra param in the URL? Just seams to be getting very complicated


    In the below example the only thing I can see that is not working is my value = "" if I set it to a static number is work, try and ref a App component and it don't I have also tried

    this.up('grid').record.get('CounterpartyId')
    
    and
    
    record.get('CounterpartyId')
    none of them work

    @(
    ]<!DOCTYPE html>
    
    <html>
    <head>
        <title>Ext.Net.MVC v2 Example</title>    
    </head>
    <body>
        @Html.X().ResourceManager()
    
        @(Html.X().GridPanel()
            .ID("DetailPanel")
            .Height(200)
            .Store(Html.X().Store()
                .Model(Html.X().Model()
                    .Fields(Html.X().ModelField().Name("test"))
                )
                .Proxy(Html.X().AjaxProxy()
                    .Url(Url.Action("GetDataForGridPanel"))
                    .Reader(Html.X().JsonReader().Root("data"))
                )
            )
            .ColumnModel(Html.X().Column()
                .Text("Test")
                .DataIndex("test")
            .Editor(
                Html.X().ComboBox()
                                                           
    
                    .ValueField("SettlementAccountId")
                    .DisplayField("Name")
                    .Store(
                    Html.X().Store()
                    .ID("StoreSettlementAccountList")
                    .AutoLoad(false)
                    .Model(Html.X().Model()
                    .Fields(
                        new ModelField("SettlementAccountId", ModelFieldType.Int),
                        new ModelField("Name", ModelFieldType.String)
                            )
    
                            )
                                                                    
                    .Proxy(
                    Html.X().AjaxProxy()
                                        .Url(Url.Action("GetSettlementAccountList"))
                                        .ExtraParams(ep =>
                                        {
                                            ep.Add(new Parameter()
                                            {
                                                Name = "id",
                                                Value = "App.DetailPanel.getRowsValues({selectedOnly:true})[0].CounterpartyId",
                                                Mode = ParameterMode.Raw
                                            }
                                            );
                                                                                            
                                                                                          
                                        }
                                        )
                                    .ActionMethods(actions =>
                                    {
    
                                        actions.Read = HttpMethod.POST;
                                    }
                                                    )
    
                        .Reader(
                        Html.X().JsonReader().Root("result")
                                )
                                                                      
    
                            )
    
                        )
    
                )    
            )
            .Plugins(Html.X().CellEditing()
              
            )
        )
    </body>
    </html>
    
    
    
    )
    Last edited by OriCoder; Jan 22, 2013 at 10:11 PM.
  7. #17
    Well, a Proxy knows nothing about GridPanel, ComboBox, editing, etc.

    So, yes, some JavaScript is required to get it working.

    But the following doesn't look complicated for me. Hope this example helps.

    Example View
    <!DOCTYPE html>
    
    <html>
    <head>
        <title>Ext.Net.MVC v2 Example</title>    
    </head>
    <body>
        @Html.X().ResourceManager()
    
        @(Html.X().GridPanel()
            .Height(200)
            .Store(Html.X().Store()
                .Model(Html.X().Model()
                    .Fields("someIdField", "test")
                )
                .Proxy(Html.X().AjaxProxy()
                    .Url(Url.Action("GetDataForGridPanel"))
                    .Reader(Html.X().JsonReader().Root("data"))
                )
            )
            .ColumnModel(
                Html.X().Column()
                    .Text("Some id field")
                    .DataIndex("someIdField"),
                Html.X().Column()
                    .Text("Test")
                    .DataIndex("test")
                    .Editor(Html.X().ComboBox()
                        .QueryMode(DataLoadMode.Local)
                        .DisplayField("text")
                        .ValueField("value")
                        .Store(Html.X().Store()
                            .AutoLoad(false)
                            .Model(Html.X().Model()
                                .Fields("value", "text")
                            )
                            .ServerProxy(Html.X().AjaxProxy()
                                .Reader(Html.X().JsonReader().Root("data"))
                                .Url(Url.Action("GetDataForComboBox"))
                            )
                        )
                )
            )
            .Plugins(Html.X().CellEditing()
                .Listeners(events =>
                {
                    events.BeforeEdit.Handler = @"var store = this.getEditor(e.record, e.column).field.getStore(); 
                                                                                                  
                                                  store.reload({
                                                      params: {
                                                          someParam: e.record.get('someIdField')
                                                      }
                                                  });";
                })
            )
        )
    </body>
    </html>
    Example Actions
    public ActionResult Index()
    {
        return View();
    }
    
    public ActionResult GetDataForCombobox(string someParam)
    {
        object[] data = new object[]
        {
            new 
            {
                text = someParam + " 1",
                value = "1"
            },
            new 
            {
                text = someParam + " 2",
                value = "2"
            },
        };
    
        return this.Store(data);
    }
    
    public ActionResult GetDataForGridPanel()
    {
        List<object> data = new List<object> 
        { 
            new { someIdField = "id1", test = "test1" },
            new { someIdField = "id2", test = "test2" },
            new { someIdField = "id3", test = "test3" }
        };
    
        return this.Store(data);
    }
  8. #18
    Sorry Danill.

    But again you are using the BeforeEdit on the GridPanel its self this then in turn effects all the comboboxes in the grid not just the one I want effected.

    E.g. Combo1, Combo2, Combo3

    Combo1 - Can be any value from a fixed list from db
    Combo2 - need to look at the result of Combo1 to get a value to generate its list from the db
    Combo 3 - looks at Combo2 to get the value to generate its list from the db

    When using direct event it is simple just tell it get records. Even if the combo knows nothing about the grid panel surely I should be able to use a direct referance to the selected row and field and pass it as a value. e.g.
    .ExtraParams(ep =>
                                        {
                                            ep.Add(new Parameter()
                                            {
                                                Name = "id",
                                                Value = "App.DetailPanel.getRowsValues({selectedOnly:true})[0].CounterpartyId",
                                                Mode = ParameterMode.Raw
                                            }
                                            );
    When using toolbar buttons which I asume would also know nothing about the gridpanel since these are also out of context being in a toolbar.
    this.up('grid')
    allows me to access the rows.

    Just to be very clear.

    I need to pass a different field depending on the combobox that is being editted and also some of them do NOT pass any field to get there lists.
  9. #19
    Apologize.

    Please clarify where are all the ComboBoxes? In the same column or different ones?

    Is there any chance for us to get a sample which would demonstrate the requirement?:) Just everything that you have already built and working (but simplified like my examples).
  10. #20
    Hi

    I it ok if I zip and PM you the solution file. That was you can see exactly what I am doing?

    Regards
Page 2 of 4 FirstFirst 1234 LastLast

Similar Threads

  1. [CLOSED] Editable Grid Panel - Razor
    By MTSI in forum 2.x Legacy Premium Help
    Replies: 2
    Last Post: Aug 22, 2012, 12:36 PM
  2. Combobox Grid Editor Dynamic
    By sysmo in forum 1.x Help
    Replies: 0
    Last Post: Aug 08, 2012, 7:36 PM
  3. Replies: 2
    Last Post: Feb 21, 2011, 5:22 AM
  4. [CLOSED] ComboBox editor in grid
    By PatrikG in forum 1.x Legacy Premium Help
    Replies: 4
    Last Post: Jul 08, 2010, 4:30 PM
  5. [CLOSED] Grid Panel editor combobox default value
    By speedstepmem2 in forum 1.x Legacy Premium Help
    Replies: 1
    Last Post: Dec 08, 2009, 8:38 AM

Tags for this Thread

Posting Permissions