PDA

View Full Version : [CLOSED] Conditional Hide GridPanel ComponentColumn



PriceRightHTML5team
Aug 20, 2014, 10:05 AM
Mine is ASP.net MVC razer view engine application.

I want to hide ComponentColumn as per value of column of respective row index.


Thanks.

Daniil
Aug 20, 2014, 11:41 AM
Hi @PriceRightHTML5team,

So, have you tried anything?

Ideally, if you can determine a ComponentColumn should be hidden before the time of rendering of GridPanel, it would be best just to set a ComponentColumn's Hidden property to true.

PriceRightHTML5team
Aug 20, 2014, 12:30 PM
Yes I have tried.

Grid Model fileds


,new ModelField("PackPayerSubSegmentId", ModelFieldType.Int)
,new ModelField("PayerSegment", ModelFieldType.String)
,new ModelField("PackPayerSubSegmentId", ModelFieldType.String)
,new ModelField("ClassificationType", ModelFieldType.String)
,new ModelField("Channel", ModelFieldType.String)
,new ModelField("AdjustmentType", ModelFieldType.String)
,new ModelField("Weight", ModelFieldType.String)

Columns

Html.X().Column().Text("New").Columns(
Html.X().ComponentColumn().Text("Channel Weight %").DataIndex("Weight")
.Editor(true)
.Component(Html.X().TextField().Hidden(true))
.Width(80).Renderer("visibility"),
Html.X().ComponentColumn().Text("Max Discount %").DataIndex("NewMaxDiscountPercent")
.Editor(true)
.Component(Html.X().TextField())
.Width(80),
Html.X().ComponentColumn().Text("Max Fees** %").DataIndex("NewMaxFeesUSD")
.Editor(true)
.Component(Html.X().TextField())
.Width(80),
Html.X().ComponentColumn().Text("AVG Deduction %").DataIndex("NewAvgDeductionPercent")
.Editor(true)
.Component(Html.X().TextField())
.Width(80)
),

With reference to above code,
I want to hide Weight Component of ComponentColumn Channel Weight on the basis of PackPayerSubSegmentId model filed value.

For your reference i have written Component property .Hidden true. But i want to set it as per model field value.

I have tried rendere;


var visiblity = function (value, meta, record, index)
{
if (record.data.PackPayerSubSegmentId == "") {
return '';

}
else {
var text = meta.column;
text.hide();
}
};

Daniil
Aug 21, 2014, 8:30 AM
It looks you need to use a ComponentColumn's BeforeBind listener. If return false from that, a ComponentColumn doesn't render its Component. A BeforeBind fires for each row and a record is being passed as argument.

PriceRightHTML5team
Aug 21, 2014, 8:34 AM
Thanks Danill,

We had also resolved this by :


.Component(Html.X().TextField()).Listeners(li=>li.BeforeBind.Handler="if(e.record.get('PackPayerSubSegmentId') != '') {e.config[0].hidden = true}")