[CLOSED] MultiSelect : Load multiselect with proxy not working

  1. #1

    [CLOSED] MultiSelect : Load multiselect with proxy not working

    Please see bellow with this code store not loaded with proxy.

    view
    @{
        Layout = null;
    }
    
    <!DOCTYPE html>
    
    <html>
    @{
        var X = Html.X();
    }
    <head>
        <meta name="viewport" content="width=device-width" />
        <title>Index</title>
    </head>
    <body>
        <div>
            @(X.ResourceManager())
           @( X.MultiSelect()
            .Height(260)
            .ID("MS1")
            .Width(300)
            .Border(true)
            .DisplayField("opText")
            .ValueField("opValue")
            .MaxSelections(1)
            .SingleSelect(true)
            .Listeners(l =>
            {
            l.Change.Handler = @"populateTag(this.getSubmitArray()[0]['value'],this.getSubmitArray()[0]['text'])";
            l.AfterRender.Handler = "App.MS1.getStore().reload()";
            })
            .Store(X.Store()
            .ID("StoreMS1")
            .Model(X.Model()
    
            .IDProperty("opValue")
            .Fields(
         
            Html.X().ModelField().Name("opValue").Type(ModelFieldType.String),
            Html.X().ModelField().Name("opText").Type(ModelFieldType.String)
            )
            )
            .AutoLoad(true)
            .ServerProxy(X.AjaxProxy()
                            .Url(Url.Action("Getoperators", "loadmultiselectwithproxy"))
            .Reader(X.JsonReader().Root("data"))
            )
            )
            )
        </div>
    </body>
    </html>
    Controller

    public class loadmultiselectwithproxyController : Controller
        {
            //
            // GET: /loadmultiselectwithproxy/
    
            public ActionResult Index()
            {
                return View();
            }
            
            public ActionResult Getoperators()
            {
    
                return this.Store(new object[]
                    {
                        new object[] { "1", "+" },
                        new object[] { "2", "-" },
                        new object[] { "3", "*" },
                        new object[] { "4", "/" },
                        new object[] { "5", "%" }
                    });
    
            }
        }
    please let me know how do I do this.

    UPDATE
    I understand ,I am creating an array of objects here,that is wrong with my code.
    can you please help me ,with proper code without create a class and then its list.

    UPDATE

    I try bellow code and working.please close this.

    public List<dynamic> Getoperators()
            {
    
                List<dynamic> data = new List<dynamic>();
                data.Add(new { opValue = "1", opText = "+" });
                data.Add(new { opValue = "2", opText = "-" });
                data.Add(new { opValue = "3", opText = "*" });
                data.Add(new { opValue = "4", opText = "/" });
                data.Add(new { opValue = "5", opText = "%" });
    
                return data;
              
    
            }
    Last edited by fabricio.murta; Feb 20, 2015 at 2:17 AM. Reason: [CLOSED]
  2. #2
    Hi
    I frequently working in firefox but today one our client reported Multiselect not populate in chrome.can you please investigate?
    Markup
    @(X.ResourceManager())
           @( X.MultiSelect()
            .Height(260)
            .ID("MS1")
            .Width(300)
            .Border(true)
            .DisplayField("opText")
            .ValueField("opValue")
            .MaxSelections(1)
            .SingleSelect(true)
            .Listeners(l =>
            {
           
            l.AfterRender.Handler = "App.MS1.getStore().reload()";
            })
            .Store(X.Store()
            .ID("StoreMS1")
            .Model(X.Model()
    
            .IDProperty("opValue")
            .Fields(
           
            Html.X().ModelField().Name("opValue").Type(ModelFieldType.String),
            Html.X().ModelField().Name("opText").Type(ModelFieldType.String)
            )
            )
            .AutoLoad(true)
            .ServerProxy(X.AjaxProxy()
                                    .Url(Url.Action("Getoperators", "loadmultiselectwithproxy"))
            .Reader(X.JsonReader().Root("data"))
            )
            )
            )
    Code

    public class loadmultiselectwithproxyController : Controller
        {
            //
            // GET: /loadmultiselectwithproxy/
    
            public ActionResult Index()
            {
                return View();
            }
    
            public ActionResult Getoperators()
            {
                return this.Store(getdate());
            }
            public List<dynamic> getdate()
            {
    
                List<dynamic> data = new List<dynamic>();
                data.Add(new { opValue = "1", opText = "+" });
                data.Add(new { opValue = "2", opText = "-" });
                data.Add(new { opValue = "3", opText = "*" });
                data.Add(new { opValue = "4", opText = "/" });
                data.Add(new { opValue = "5", opText = "%" });
    
                return data;
                
    
            }
        }
    with above code Multiselect pupulate in Firefox ,but blank (not populate with data) in chrome(version : 39.0.2171.99 m)
  3. #3
    Hi
    any thought on this?
  4. #4
    Hello, @matrixwebtech,

    Sorry for the delay, we tend to skip [CLOSED] topics as we don't expect much activity from them. But luckily @dimitris found this today and pointed us. I'll be looking at your matter and I hope to give you an alternative soon.

    I didn't check if I can run your code here, just leaving you a feedback.
    Fabrício Murta
    Developer & Support Expert
  5. #5
    Setting Autoload to false seems to fix the issue. This definition is on your view code line 27.

    Is this an acceptable solution in your context?
    Fabrício Murta
    Developer & Support Expert
  6. #6
    Hi fabricio.murta

    Thankx for reply,your solution works.but one question ,can you please tell me why previously code behave different in different browser ,you can also close this thread.
  7. #7
    Hi @matrixwebtech,

    You know, different browsers act differently on situations they weren't supposed to. I noticed in some situations changing the code even on IE the symbols you loaded briefly were displayed and then vanished. Then I realised something was calling again the loader: which was the autoLoad mechanism.

    In fact, if autoLoad is enabled, in some situations it makes undesired side effects. If you search the forums on autoLoad I believe you will find some issues (at least one) that was fixed by setting it to false too. It seems another undesired side effect is calling the layout renderer events twice. I didn't confirm yet everything I said on this last paragraph, but reality will not be far from this.
    Fabrício Murta
    Developer & Support Expert

Similar Threads

  1. [CLOSED] Populate TagField From Multiselect and Remove Item from Multiselect
    By matrixwebtech in forum 2.x Legacy Premium Help
    Replies: 12
    Last Post: Oct 13, 2014, 2:44 PM
  2. Replies: 0
    Last Post: Oct 12, 2012, 10:45 AM
  3. Replies: 4
    Last Post: May 09, 2012, 9:24 PM
  4. Replies: 4
    Last Post: Feb 20, 2012, 11:14 AM
  5. Replies: 0
    Last Post: Mar 09, 2010, 7:28 AM

Posting Permissions