PDA

View Full Version : [CLOSED] How to get column header name on grid panel cell's right click



arjunrvasisht
May 18, 2015, 11:40 AM
I am creating a grid panel dynamically. While creating am locking the first 3 columns. So that the horizontal scroll bar starts from the 4th column. I have context menu implemented for the grid which should not be enabled for the locked columns. I have an event written inside the view config of a grid like below to prevent the right click:



<ViewConfig>
<Listeners>
<CellContextMenu Fn="preventRightClick" />
</Listeners>
</ViewConfig>


Function definition:


preventRightClick = function (view, td, cellIndex, record, tr, rowIndex, e){

var abc = #{grdETSummary};
#{HdnColumnIndex}.setValue(cellIndex);
if((cellIndex == "0")||(cellIndex == "1")||(cellIndex == "2"))
{
#{tier1SummaryMenu}.disable();
#{tier2SummaryMenu}.disable();
}
else
{
#{tier1SummaryMenu}.enable();
#{tier2SummaryMenu}.enable();
}

e.preventDefault();
}


The problem is after locking the first 3 (0,1,2) columns, the column index of the 4th column in the javascript function again starts from 0 instead of starting from 3. So as per my grid, the columns 3,4,5 also disables the context menu. If I can get the column header name in the click event then I can restrict it from being disabled. Please tell me how do I get the column header name WITHOUT USING THE COLUMN INDEX.!! Well, if I had to use the column index to find the column header again it results in the same way as the unlocked column index starts from 0.

EnZo
May 18, 2015, 12:16 PM
Hi arjunrvasisht

Does
view.panel.columns; return all columns including locked and unlocked?

arjunrvasisht
May 18, 2015, 5:57 PM
Hi EnZo,

It returns only unlocked columns.

Prasoon
May 19, 2015, 11:24 AM
Hi Arjun,

when you work with locked columns, then in that case you have different view ids for locked and unlocked columns, try to check "view.id" and enable/disable context menu in your preventRightClick function.

Regards,
Prasoon

arjunrvasisht
May 21, 2015, 4:58 AM
Thanks Prasoon :)
I will give a try right now..! It should work.