Hi Daniil,
As requested, see below full test case to reproduce.
Model (TestCaseModel.cs):
using System;
using System.Collections;
namespace TestCase
{
public class TestDataModel
{
public int IntField2 {get; set;}
public int ComboField2 {get; set;}
public string TextField2 {get; set;}
public DateTime DateField2 { get; set; }
}
public class TestData
{
public static IEnumerable GetData()
{
DateTime now = DateTime.Now;
return new object[]
{
new object[] { 1, 1, "Text 1", DateTime.Now.Date },
new object[] { 2, 2, "Text 2", DateTime.Now.Date },
new object[] { 3, 3, "Text 3", DateTime.Now.Date },
new object[] { 4, 4, "Text 4", DateTime.Now.Date },
new object[] { 5, 5, "Text 5", DateTime.Now.Date },
new object[] { 6, 6, "Text 6", DateTime.Now.Date },
new object[] { 7, 7, "Text 7", DateTime.Now.Date },
new object[] { 8, 8, "Text 8", DateTime.Now.Date },
new object[] { 9, 9, "Text 9", DateTime.Now.Date }
};
}
}
}
View (Index.cshtml):
@model System.Collections.IEnumerable
@using Ext.Net
@using Ext.Net.MVC
@{
ViewBag.Title = "Test Case";
var X = @Html.X();
}
@section scripts{
<script>
var BeforeQuery = function () {
this.getStore().load({ params: { id: this.record.data.IntField } });
};
</script>
}
@section main
{
@X.ResourceManager()
<h1>Test Case ComponentColumn using Ext.Net.MVC5 2.4</h1>
<p>Steps to reproduce:</p>
<ol>
<li>Refresh the page.</li>
<li>Click the arrow down in the first combobox. Notice that the dropdown list will not appear yet.</li>
<li>Click the first combo again. It will now display the dropdown list.</li>
<li>Same with the remaining combo boxes.</li>
</ol>
@(Html.X().GridPanel()
.Title("Test Case ComponentColumn Editor - 28113")
.Width(600)
.Height(300)
.Store(Html.X().Store()
.Model(Html.X().Model()
.Fields(
new ModelField("IntField", ModelFieldType.Int),
new ModelField("ComboField", ModelFieldType.Int),
new ModelField("TextField", ModelFieldType.String),
new ModelField("DateField", ModelFieldType.Date)
)
)
.DataSource(Model)
)
.ColumnModel(
X.ComponentColumn()
.Editor(true)
.Text("Test Case Problem Field")
.Flex(1)
.DataIndex("TextField")
.Component(
X.ComboBox()
.DisplayField("TextField2")
.ValueField("IntField2")
.QueryMode(DataLoadMode.Local)
.TriggerAction(TriggerAction.All)
.Store(
X.Store()
.AutoLoad(false)
.Model(
X.Model()
.Fields(
new ModelField("IntField2", ModelFieldType.Int),
new ModelField("ComboField2", ModelFieldType.Int),
new ModelField("TextField2", ModelFieldType.String),
new ModelField("DateField2", ModelFieldType.Date)
)
)
.Proxy(
X.AjaxProxy()
.Url(Url.Action("GetTestData"))
.Reader(
X.JsonReader().Root("data")
)
)
)
.Listeners(l => l.BeforeQuery.Fn = "BeforeQuery")
)
)
)
}
Controller (TestCaseController.cs):
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using Ext.Net;
using Ext.Net.MVC;
namespace TestCase
{
public class TestCaseController : Controller
{
public ActionResult Index()
{
return View(TestData.GetData());
}
public StoreResult GetTestData(string id)
{
StoreResult storeResult = new StoreResult();
try
{
var list = new List<TestDataModel>();
foreach (object[] obj in TestData.GetData())
{
TestDataModel t = new TestDataModel();
t.IntField2 = Convert.ToInt32(obj[0]);
t.ComboField2 = Convert.ToInt32(obj[1]);
t.TextField2= obj[2].ToString();
t.DateField2= Convert.ToDateTime(obj[3]);
list.Add(t);
}
storeResult = new StoreResult(list);
}
catch (Exception ex)
{
throw ex;
}
return storeResult;
}
}
}
Versions:
- .NET Framework 4.5
- MVC 5.1
- Ext.Net MVC5 2.4.0.28941
Purpose / Objective:
- To pass the IntField value into the ComboBox Store as StoreParameter/Parameter in order to get rid of BeforeQuery listener.
{ params: { id: this.record.data.IntField } }
How To?
.Proxy(
X.AjaxProxy()
.Url(Url.Action("GetTestData"))
.Reader(
X.JsonReader().Root("data")
)
.Parameters(ps =>
ps.Add(new StoreParameter("id", "???"))
)
)
Looking forward for your utmost response.
Thanks.