Hi,
I am developing a webform that has a webgrid. The grid is supposed to be able to allow the user to select the text inside the cell. The only problem I have is that some of the cell have also a JS functionality (cellclick) that I need to handle. Using the ReadOnly property for the grid, I am able to select the text inside a cell, but I am not able to fire the CellClick event. Is there any other way to be able to select a text (or part of a text) and also use the fully functionality for a cell?
Regards,
Aurelian
Tony, that is not what I want. I don't want to setValue to a cell, but to highlight the cell and to be able to have the copy functionality like the normal cell in a HTML table cells. Also, and I repeat, I don't want to loose the functionality of the cell (cellclick, or doubleclick). The example that you gave me is to set value to a cell. Could you please give another example that shows me how to highligt the cell?
Thanks for your help,
Aurelian,
You'll want to add an event handler to the grid's main element. Don't use the grid's id exactly, or you'll just end up with getting a reference to the hidden input field for the grid.
Here's a code snippet. This uses MS AJAX.
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>Untitled Page</title>
<script type="text/javascript">
function pageLoad(sender, args)
{
var grd=$get("G_grid");
$addHandler(grd,"click",grid_click);
}
function grid_click(args)
var cell=igtbl_getCellById(args.target.id);
if(cell)
cell.setValue("hello");
</script>
</head>
<body>
<form id="form1" runat="server">
<asp:ScriptManager ID="sm" runat="server">
</asp:ScriptManager>
<div>
<igtbl:UltraWebGrid runat="server" ID="grid">
<Bands>
<igtbl:UltraGridBand>
<Columns>
<igtbl:UltraGridColumn Key="col1">
</igtbl:UltraGridColumn>
<igtbl:UltraGridColumn Key="col2">
</Columns>
</igtbl:UltraGridBand>
</Bands>
<Rows>
<igtbl:UltraGridRow>
</igtbl:UltraGridRow>
</Rows>
</igtbl:UltraWebGrid>
</div>
</form>
</body>
</html>
Tony, can I have a simple example that I can use?
You can manually attach a click event to the grid's table element, and use the srcElement on the event parameter to get the exact cell in question.
-Tony