PDA

View Full Version : [CLOSED] MultiSelect : Load multiselect with proxy not working



matrixwebtech
Dec 26, 2014, 6:02 PM
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;


}

matrixwebtech
Feb 18, 2015, 2:52 PM
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)

matrixwebtech
Feb 19, 2015, 2:23 PM
Hi
any thought on this?

fabricio.murta
Feb 19, 2015, 8:58 PM
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.

fabricio.murta
Feb 19, 2015, 9:28 PM
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?

matrixwebtech
Feb 20, 2015, 1:47 AM
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.

fabricio.murta
Feb 20, 2015, 4:01 PM
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.