Welcome Guest Search | Active Topics | Sign In | Register

To get the style backcolor from cell before to show contextmenu Options
Guerrero
Posted: Wednesday, January 27, 2010 6:05:51 PM
Rank: Newbie
Groups: Member

Joined: 1/5/2010
Posts: 4
HELLO;

SORRY NOT MUCH OF ENGLISH, BUT I'LL TRY TO EXPLAIN. PAINT THE CELLS OF A GRID WITH CSS. BUT NOW I NEED TO GET THE BACKGROUND COLOR OF THE CELL. Before showing the ContextMenu and BACKCOLOR ADD ITEMS DEPENDING ON CELL.

var g_itemIndex = -1;
var g_cellIndex = -1;

function ShowContextMenu(e, grid, item, cell)
{
g_itemIndex = item.getIndex();
g_cellIndex = cell.getColIndex();
var pValor = cell.getValue();
var gridItem = grid.getItem(g_itemIndex);
var pColEstacion = gridItem.getCell(0).getValue();
var pSINO_Menu_Contextual = false;
var pLblCredenciales = document.getElementById("LblCredenciales");
var pCredenciales = pLblCredenciales.innerText;
var pFragmentoCredencial = pCredenciales.split(',');
var pUsuario = pFragmentoCredencial[0];
var pCategoria = pFragmentoCredencial[1];
var pNivelSector = pFragmentoCredencial[2];
var pLboSector = document.getElementById("LboSector");
if (pCategoria == "Administrador" || pCategoria == "Operador" && pNivelSector == pLboSector.value || pNivelSector == "TODO")
{
if(g_cellIndex >=5 && pValor !="" && pColEstacion !="")
{
var pColumnaAntes = g_cellIndex - 1;
var pValorAntes = gridItem.getCell(pColumnaAntes).getValue();
if (typeof parseFloat(pValorAntes) == "number" && typeof parseFloat(pValor) == "number")
{
var pLboDiferencia = document.getElementById("LboDiferencia").value;
var pDiferencia = pValor - pValorAntes;
if (pDiferencia <= (parseFloat(pLboDiferencia) * -1))
{

//SORRY NOT MUCH OF ENGLISH, BUT I'LL TRY TO EXPLAIN.
//PAINT THE CELLS OF A GRID WITH CSS. BUT NOW I NEED TO
//GET THE BACKGROUND COLOR OF THE CELL.
//Before showing the ContextMenu and BACKCOLOR ADD ITEMS DEPENDING ON CELL


var pMenuContextual = eo_GetObject("<%=Menu1.ClientID%>");
//pMenuContextual.getTopGroup().getItemByIndex(0).setText("Modificando Menu");
eo_ShowContextMenu(e, "<%=Menu1.ClientID%>");
pSINO_Menu_Contextual = true;
}
else if (pDiferencia >= parseFloat(pLboDiferencia))
{
var pMenuContextual = eo_GetObject("<%=Menu1.ClientID%>");
eo_ShowContextMenu(e, "<%=Menu1.ClientID%>");
pSINO_Menu_Contextual = true;
}
}
}
}
return pSINO_Menu_Contextual;
}

function OnContextMenuItemClicked(e, eventInfo)
{
var grid = eo_GetObject("<%=Grid1.ClientID%>");
var item = eventInfo.getItem();
switch (item.getText())
{
case "Agregar Justificacion":
var gridItem = grid.getItem(g_itemIndex);
var pColumnaAyer = g_cellIndex - 1;
var pLboSector = document.getElementById("LboSector");
var pLboMes = document.getElementById("LboMes");
var pLboAnio = document.getElementById("LboAnio");
var pSector = pLboSector.value;
var pEstacion = gridItem.getCell(0).getValue();
var pSeparador = gridItem.getCell(1).getValue();
var pDato = gridItem.getCell(2).getValue();
var pFecha_Diferencia = (g_cellIndex - 4) + '-' + pLboMes.value + '-' + pLboAnio.value;
var pProdHoy = gridItem.getCell(g_cellIndex).getValue();
var pProdAyer = gridItem.getCell(pColumnaAyer).getValue();
var pDiferencia = pProdHoy - pProdAyer;
var pDiferenciaround = Math.round(pDiferencia*100)/100;
var pLblCredenciales = document.getElementById("LblCredenciales").innerText;
var pFragmentoCredencial = pLblCredenciales.split(',');
var pUsuario = pFragmentoCredencial[0];
var pParametrosJustificacion = pSector + ',' + pEstacion + ',' + pSeparador + ',' + pDato + ',' + pFecha_Diferencia + ',' + pProdHoy + ',' + pProdAyer + ',' + pDiferenciaround + ',' + pUsuario;
eo_Callback('CallbackPanel_Mantenimiento',pParametrosJustificacion);
var pDialogoMantto = eo_GetObject('DialogoMantenimiento');
pDialogoMantto.setCaption('Agregar Justificacion de Caida de produccion')
pDialogoMantto.show(true);
break;
case "Modificar Justificacion":
alert('Modificar Justificacion se encuentra en Desarrollo');
break;
case "Modificar Valor":
alert('Modificar Valor de produccion se encuentra en Desarrollo');
break;
}
}
eo_support
Posted: Wednesday, January 27, 2010 6:21:42 PM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,194
Hi,

I am sorry, but I do not understand your question. Your code looks good to us. Is it not working?

Thanks!
Guerrero
Posted: Wednesday, January 27, 2010 6:38:53 PM
Rank: Newbie
Groups: Member

Joined: 1/5/2010
Posts: 4
YES, IT WORKS ! BUT I NEED TO KNOW DE BACK COLOR FROM THE CELL I CLICKED AND DO SOME FUNCTION FOR ADD NEW ITEMS AT THE CONTEXTMENU, DEPENDING OF THE BACKCOLOR FROM DE CELL. ALL EVERYTING BEFORE TO SHOW THE CONTEXTMENU.

function ShowContextMenu(e, grid, item, cell)
{

// HERE I GET THE CELL
// HERE SOME FUNCTION BEFORE TO SHOW CONTEXTMENU DEPENDING THE BACKCOLOR OF THE CELL
// AND MODIFY THE ITEM TEXT OR NOT VISIBLE

//pMenuContextual.getTopGroup().getItemByIndex(0).setText("Modificando Menu");



}

function OnContextMenuItemClicked(e, eventInfo)
{
// CONTEXTMENU WITH NEW ITEMS OR CHANCHED ITEM TEXT
}


eo_support
Posted: Wednesday, January 27, 2010 7:13:11 PM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,194
Hi,

You can not get the color of the cell. You can only get the cell's "Value". So if your color comes from a database field (for example, by using GridColumn.StyleField), you can add another column and store the value of that field into this new column. You can then set this new column's Visible to false so that it is not visible to the user. In your code you can access this hidden columns' cell value to determine the color of your visible column.

Hope this helps.

Thanks!
Guerrero
Posted: Thursday, January 28, 2010 9:39:40 AM
Rank: Newbie
Groups: Member

Joined: 1/5/2010
Posts: 4
hi,

everiting that you told me i maked, i was fill de grid with CSS cell by cell, but i dont know how to get de backcolor of cell with javascript. just i know to get with VB .net that some like this

Dim LlegadaValores() As String = Split(eventArgument, ",", -1)
Dim pArgumento As String = LlegadaValores(0)
Dim pValor_F As Integer = LlegadaValores(1)
Dim pValor_C As Integer = LlegadaValores(2)
Try
Select Case (pArgumento)
Case "BuscaFondo"
m_CallbackResultado = Grid1.Items.Item(pValor_F).Cells(pValor_C).Style.ToString
End Select
Catch ex As Exception
m_CallbackResultado = "ERROR AL BUSCAR EL FONDO DE LA CELDA"
End Try



And with this i can get the name of css class. but need help for to get the name of the class in client side. for to do some function before to show the contextmenu, some like to change the item name the menu or make it not visible some item.

i hope that you understand me. please a need your help!!!!

thank you.


i forgot i find some in this link:
http://www.essentialobjects.com/forum/postst4200_Grid-styling.aspx

And you said that you can change the name of the value the colum or backcolor with css, you said that.


You will always set the style on the server side and then "override" it on the client side. Also you can only override style on the cell level. For example, because you can only override cell styles on the client side, there is no JavaScript interface for you to turn the column header from red to blue (of course you can always use the DIV trick without going through the Grid at all).

To change a cell's style, first get the cell object, then do something like this:

cell.overrideStyle("your_css_rule_name");

This is conceptually the same as cell.className = "your_css_rule_name" except that a lot of other details needed to be taken care of inside the grid.

Because you will almost always rely on styles setting on the server side as well, so make sure you go over the previous link we provided to you. You will also want to go over the following link if you are not familiar with our client side API:

http://doc.essentialobjects.com/library/1/clientapi_howto.aspx

You can find the corresponding content in your local help file. The local version is more updated than the online version (the online version does not have overrideStyle function, but your local version should have it).



with this i think that you can help me.
thank you one more time...

im waitting your answer


eo_support
Posted: Thursday, January 28, 2010 9:47:54 AM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,194
Hi,

You did not understand our previous reply correctly. You can NOT get the css class directly from a Grid cell. If you want to get it, you must store it at another place and get it from that other place, not from the cell itself. You can use an additional hidden column as a storage place to store this vlaue. So basically:

1. You will have two cells Cell_A and Cell_B. Cell_A is visible, Cell_B is not (because it is from another hidden column);
2. When you set style on Cell_A, you also store it into Cell_B as Cell_B’s value;
3. If you want to get Cell_A's style, you get Cell_B's value;

Note here "style" and "value" are two different things. Each cell has a style and a value. You can only "set" style. However you can "get" and "set" value.

Hope this clears up.

Thanks!
Guerrero
Posted: Thursday, January 28, 2010 10:03:58 AM
Rank: Newbie
Groups: Member

Joined: 1/5/2010
Posts: 4
OK

THIS TIME I UNDERSTAD. IM GOING TO MAKE THAT

THANKS FOR ALL.



You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.