Oct 03, 2014, 12:48 AM
[CLOSED] Selecting a row in a non-rendered gridpanel may cause an error
Hi:
To reproduce run the code below and click on the Click Me button (don't go to the second tab before clicking the botton).
I modified the MVC GridPanel/ArrayGrid/Simple sample.
The error that is thrown is: Uncaught TypeError: Cannot read property 'indexOf' of undefined.
When you reproduce the error you'll get the full stack.
The reason I am mentioning this is that it didn't use to fail with an error in Ext.Net 2.1.1.
Thanks
To reproduce run the code below and click on the Click Me button (don't go to the second tab before clicking the botton).
I modified the MVC GridPanel/ArrayGrid/Simple sample.
The error that is thrown is: Uncaught TypeError: Cannot read property 'indexOf' of undefined.
When you reproduce the error you'll get the full stack.
The reason I am mentioning this is that it didn't use to fail with an error in Ext.Net 2.1.1.
Thanks
using System;
using System.Collections;
using System.Web.Mvc;
using Ext.Net.MVC.Examples.Areas.GridPanel_ArrayGrid.Models;
namespace Ext.Net.MVC.Examples.Areas.GridPanel_ArrayGrid.Simple.Controllers
{
public class SimpleController : Controller
{
public ActionResult Index()
{
return View(Companies.GetAllCompanies());
}
public StoreResult GetData()
{
object[] allCompanies = Companies.GetAllCompanies();
Array.Reverse(allCompanies);
return this.Store(allCompanies, allCompanies.Length);
}
}
}
@using System.Web.UI.HtmlControls
@model System.Collections.IEnumerable
@{
ViewBag.Title = "Simple Array Grid - Ext.NET MVC Examples";
Layout = "~/Views/Shared/_BaseLayout.cshtml";
}
@section headtag
{
<style>
.x-grid-row-over .x-grid-cell-inner {
font-weight : bold;
}
</style>
<script>
var template = '<span style="color:{0};">{1}</span>';
var change = function (value) {
return Ext.String.format(template, (value > 0) ? "green" : "red", value);
};
var pctChange = function (value) {
return Ext.String.format(template, (value > 0) ? "green" : "red", value + "%");
};
</script>
}
@section example
{
<h1>Simple Array Grid x</h1>
@(Html.X().Store()
.ID("companiesStore")
.Model(Html.X().Model()
.Fields(
new ModelField("company"),
new ModelField("price", ModelFieldType.Float),
new ModelField("change", ModelFieldType.Float),
new ModelField("pctChange", ModelFieldType.Float),
new ModelField("lastChange", ModelFieldType.Date, "M/d hh:mmtt")
)
)
.Proxy(
Html.X().AjaxProxy().Url("~/GridPanel_ArrayGrid/Simple/GetData").Reader(Html.X().ArrayReader().Root("data"))
)
)
@(
Html.X().TabPanel()
.DeferredRender(true)
.TopBar(Html.X().Toolbar().Items(
Html.X().Button()
.Text("Click me")
.Listeners(l => l.Click.Handler = "#{secondGridPanel}.bindStore(#{companiesStore}); #{secondGridPanel}.getSelectionModel().select(0);")
))
.Items(
Html.X().GridPanel()
.Title("Array Grid 1")
.Width(600)
.Height(350)
.Store(Html.X().Store()
.Model(Html.X().Model()
.Fields(
new ModelField("company"),
new ModelField("price", ModelFieldType.Float),
new ModelField("change", ModelFieldType.Float),
new ModelField("pctChange", ModelFieldType.Float),
new ModelField("lastChange", ModelFieldType.Date, "M/d hh:mmtt")
)
)
.DataSource(Model)
)
.ColumnModel(
Html.X().Column().Text("Company").DataIndex("company").Flex(1),
Html.X().Column().Text("Price").DataIndex("price").Renderer(RendererFormat.UsMoney),
Html.X().Column().Text("Change").DataIndex("change").Renderer("change"),
Html.X().Column().Text("Change").DataIndex("pctChange").Renderer("pctChange"),
Html.X().DateColumn().Text("Last Updated").DataIndex("lastChange")
),
Html.X().GridPanel()
.Title("Array Grid 2")
.ID("secondGridPanel")
.Width(600)
.Height(350)
.ColumnModel(
Html.X().Column().Text("Company").DataIndex("company").Flex(1),
Html.X().Column().Text("Price").DataIndex("price").Renderer(RendererFormat.UsMoney),
Html.X().Column().Text("Change").DataIndex("change").Renderer("change"),
Html.X().Column().Text("Change").DataIndex("pctChange").Renderer("pctChange"),
Html.X().DateColumn().Text("Last Updated").DataIndex("lastChange")
)
)
)
}
Last edited by Daniil; Oct 04, 2014 at 7:39 AM.
Reason: [CLOSED]