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

radGrid Context menu issue

2 Answers 83 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Mridul
Top achievements
Rank 2
Mridul asked on 11 Nov 2008, 09:42 AM
Hi,

I'm using radgrid with a context menu. Upon clicking the id column of the row is saved in a hidden textbox. The context menu uses the textbox value to open a radwindow. Following is the related code.

 function RowContextMenu(sender, eventArgs) 
            { 
                var menu = $find("<%=RadMenu1.ClientID %>"); 
                var evt = eventArgs.get_domEvent(); 
                 
                if(evt.target.tagName == "INPUT" || evt.target.tagName == "A"
                { 
                  return
                } 
               var dataItem = $get(eventArgs.get_id()); 
               var grid = sender; 
               var MasterTable = grid.get_masterTableView(); 
               var row = MasterTable.get_dataItems()[dataItem.rowIndex-1]; 
               var cell = MasterTable.getCellByColumnUniqueName(row, "TicketNo"); 
              //here cell.innerHTML holds the value of the cell 
              var TicketNo = cell.innerText; 
         
                var index = eventArgs.get_itemIndexHierarchical(); 
                document.getElementById("radGridClickedRowIndex").value = TicketNo; 
                sender.get_masterTableView().selectItem(sender.get_masterTableView().get_dataItems()[index].get_element(), true); 

                menu.show(evt); 
                 
                evt.cancelBubble = true
                evt.returnValue = false
 
                if (evt.stopPropagation) 
                { 
                   evt.stopPropagation(); 
                   evt.preventDefault(); 
                } 
            } 





When a context menu item is clicked:

function onClicking(sender, eventArgs) 
            { 
             
              var item = eventArgs.get_item(); 
              var navigateUrl = item.get_text(); 
              var ticketNo = document.getElementById("radGridClickedRowIndex").value; 
              if (navigateUrl == "Reassign"
              { 
                 var oWindow = window.radopen ("Reassign.aspx?INC=" + ticketNo, null); 
                 oWindow.setSize(300,200); 
                 oWindow.moveTo(400, 300);    
                 oWindow.add_close(OnClientClose); 
              } 


The issue occurs on grouping the grid with 2 or more columns. It works fine with first few rows(5-7) but as we go down to lower rows, I get

Microsoft JScript runtime error: 'undefined' is null or not an object

It breaks on following code:
getCellByColumnUniqueName:function(_1de,_1df){ 
for(var i=0;i<this.get_columns().length;i++){ 
if(this.get_columns()[i].get_element().UniqueName.toUpperCase()==_1df.toUpperCase()){ 
return _1de.get_element().cells[i]; <-- This is where the error points -->

Please look into this issue. Going by the function name it looks like its a grid related issue.

Edit: System Info
Web.UI Version - 2008.1.515.35
.NET Framework - 3.5
Visual Studio 2008
Browser - IE 7


Regards
Mridul

2 Answers, 1 is accepted

Sort by
0
Mridul
Top achievements
Rank 2
answered on 11 Nov 2008, 10:22 AM
I found what is the issue here.

When radGrid is grouped on a column; an additional row is added on top. Clicking first row actually returns id column from second row as it is supposed to be in second row had grouping not been done.

It does not return any errors in first few rows because of the offset caused by grouping as it can find items on the same page. It returns error in accessing last few elements of the grid as their offset rows are on the next page of radgrid.

So, let me rephrase my question:

How do I select Column Key value, when a row is selected in a hierarchical grid?
0
Accepted
Yavor
Telerik team
answered on 11 Nov 2008, 01:14 PM
Hi Mridul,

To see more information along the lines of the requested functionality, please refer to the following article, as well as this one. I hope these resources get you started properly.

Kind regards,
Yavor
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
Tags
Grid
Asked by
Mridul
Top achievements
Rank 2
Answers by
Mridul
Top achievements
Rank 2
Yavor
Telerik team
Share this question
or