PDA

View Full Version : [CLOSED] Disable cell editor based on row value



susanz
Jan 07, 2015, 8:13 PM
I want to use you GridPanel-> OverEditor demo, but how do I disable the cell editors if the record.editable is not true ?
Thanks
-szhang
Your demo code below:


@(Html.X().GridPanel()
.Title("ComponentColumn Over Editor")
.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(
Html.X().ComponentColumn()
.Editor(true)
.OverOnly(true)
.DataIndex("IntField")
.Flex(1)
.Text("Integer")
.Component(Html.X().NumberField()),

Html.X().ComponentColumn()
.Editor(true)
.OverOnly(true)
.DataIndex("ComboField")
.Flex(1)
.PinEvents("expand")
.UnpinEvents("collapse")
.Text("ComboBox")
.Component(Html.X().ComboBox()
.Items(
new ListItem("Item 1", 1),
new ListItem("Item 2", 2),
new ListItem("Item 3", 3),
new ListItem("Item 4", 4),
new ListItem("Item 5", 5),
new ListItem("Item 6", 6),
new ListItem("Item 7", 7),
new ListItem("Item 8", 8),
new ListItem("Item 9", 9)
)
),

Html.X().ComponentColumn()
.Editor(true)
.OverOnly(true)
.DataIndex("TextField")
.Flex(1)
.Text("Text")
.Component(Html.X().TextField()),

Html.X().ComponentColumn()
.Editor(true)
.OverOnly(true)
.DataIndex("DateField")
.Flex(1)
.PinEvents("expand")
.UnpinEvents("collapse")
.Text("Date")
.Renderer(new Renderer()
{
Format = RendererFormat.Date,
FormatArgs = new string[] { "'d/m/Y'" }
})
.Component(Html.X().DateField().Format("dd/MM/yyyy"))
)
)

Daniil
Jan 08, 2015, 12:11 PM
Hi @susanz,

Returning false from a ComponentColumn's BeforeBind handler prevents appearing of Component.

X.ComponentColumn()
.Listeners(events =>
events.BeforeBind.Handler = "return !!e.record.data.editable;"
)

susanz
Jan 08, 2015, 3:52 PM
Thank you so much Daniil. It works!
-szhang