您的位置:首页 > 编程语言 > ASP

ASPxGridView 单元格、数据行动态操作

2012-11-20 16:49 344 查看
对于单元格的操作,只需在事件HtmlDataCellPrepared添加事件 。

.cs

/// <summary>
/// 单元格单击处理
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void InputByBatchIndexList_HtmlDataCellPrepared(object sender, ASPxGridViewTableDataCellEventArgs e)
{

string rows = e.VisibleIndex.ToString();
string cols = e.DataColumn.Index.ToString();
string rowAndCols = rows + "," + cols;

if (e.DataColumn.Caption=="Name")
{
if (e.GetValue("Name")!=null)
e.Cell.ToolTip = Convert.ToString(e.GetValue("Name"));  //对Name列的单元格,增加tooltip的显示
}


e.Cell.Attributes.Add("onmousedown", "PieceNumberClicked('" + rowAndCols + "');this.style.backgroundColor='#FFE7A2';");
e.Cell.Attributes.Add("ondblclick", "this.style.backgroundColor='#FFFFFF';");

}

.aspx

<script type="text/javascript" src="../js/jquery-1.3.2.min.js"></script>
<script type="text/javascript">
function PieceNumberClicked(value)
{
values=value;
var nowTime=(new Date()).getTime();
var strs= new Array(); //定义一数组
strs=values.split(","); //字符分割
var row=strs[0];
var col=strs[1];

if(col>6)
{
$.getJSON("data/AjaxGetMethod.aspx", { "param": values,"timestamp":nowTime}, function(data, textStatus)
{

$("#F_JDCLJG").html(data[0].F_JDCLJG);
$("#F_PDJGFH").html(data[0].F_PDJGFH);
$("#F_PDYJ").html(data[0].F_PDYJ);
$("#F_ValueAVG").html(data[0].F_ValueAVG);
$("#F_AVGValPDJGFH").html(data[0].F_AVGValPDJGFH);
$("#F_ValueDIF").html(data[0].F_ValueDIF);
$("#F_DeviateType").html(data[0].F_DeviateType);
$("#F_DifJudgeBound").html(data[0].F_DifJudgeBound);
});

}
else
{
$("#F_JDCLJG").html("");
$("#F_PDJGFH").html("");
$("#F_PDYJ").html("");
$("#F_ValueAVG").html("");
$("#F_AVGValPDJGFH").html("");
$("#F_ValueDIF").html("");
$("#F_DeviateType").html("");
$("#F_DifJudgeBound").html("");
}

}

</script>

对于行数据的操作,后续待添加
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: