This is a migrated thread and some comments may be shown as answers.

Migrating OnRowCreated event from Q3 2007 to Q2 2009 version

3 Answers 33 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Meenakshi Nagalingam
Top achievements
Rank 1
Meenakshi Nagalingam asked on 07 May 2010, 11:37 AM

Hi,

Earlier we were using rad grid version of Q3 2007. Now we are migrating it to Q2 2009.

My OnRowCreated event goes like this,

function onRowCreated(rowObject)
    {
        if(rowObject.ItemType == "NestedView")
        {
            var nestedTable = rowObject.Control.cells[1].childNodes[0];

            if(nestedTable != null && nestedTable.tBodies[0].rows.length == 1 && nestedTable.innerHTML.indexOf("No child records to display.") != -1)
            {
                var parentRow = this.Control.rows[rowObject.Control.rowIndex - 1];
                parentRow.cells[0].childNodes[0].style.display = "none";
                rowObject.Control.style.display = "none";
            }
        }
    }

Now i need to convert this to rad grid version of Q2 2009.
I couldnt find how to convert rowObject.ItemType to the latest one.

If anybody knows how to convert this above function to the Q2 2009 version please let me know.

Thanks in advance

3 Answers, 1 is accepted

Sort by
0
Tsvetoslav
Telerik team
answered on 11 May 2010, 11:27 AM
Hi Meenakshi,

Attached is a small sample demonstrating how to achieve the requirement in question.

Hope it helps.

Greetings,
Tsvetoslav
the Telerik team

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
0
Meenakshi Nagalingam
Top achievements
Rank 1
answered on 12 May 2010, 09:41 AM
Hi Tsvetoslav,

Thanks for the response.

But, is there any way to retrieve the ItemType? Because we want to indentify the "Item" and "AlternatingItem" separately.
We are assigning the row color based on the item type in MouseOut.

My client event tag goes like this,
<ClientEvents OnRowMouseOver="ChangeColor" OnRowMouseOut="RemoveColor" />

The javascript functions goes like this,

 

var rowMouseOverColor = '#FFDAB9'; 
var rowAlternatingColor = 'white';  
var rowItemColor = '#F2F9FF';

 

 

 

 

function ChangeColor(index)
     {
        this.Rows[index].Control.style.cursor = 'hand';
        this.Rows[index].Control.style.backgroundColor =  rowMouseOverColor;
     }

 function RemoveColor(index)
     {        
        if(this.Rows[index].ItemType == "Item")
        {
             this.Rows[index].Control.style.backgroundColor = rowItemColor; 
        }
        else if(this.Rows[index].ItemType == "AlternatingItem")
        {
            this.Rows[index].Control.style.backgroundColor = rowAlternatingColor;  
        }    
     }

It will be usefulf if there is a way to find the Item type using javascript.

0
Tsvetoslav
Telerik team
answered on 14 May 2010, 10:26 AM
Hi Meenakshi,

The client-side item objects were designed differently in the older version of the controls and currently they do not support this property for optimization purposes (to keep the response size as small as possible). However, you can easily implement a work-around by getting the item index and going by it ascertain whether it is an alternating item or not. Another approach is to work with the css class of the table row - both in the skins of the grid and in your custom implementation it will be different for the regular and the alternating items.

Regards,
Tsvetoslav
the Telerik team

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
Tags
Grid
Asked by
Meenakshi Nagalingam
Top achievements
Rank 1
Answers by
Tsvetoslav
Telerik team
Meenakshi Nagalingam
Top achievements
Rank 1
Share this question
or