行数据中,发货地可用量小于等于0时,底色变红(因为可用量小于等于0时,不可选择拉单)
public void AfterCreateChildControls()
{
RegisterTdStoreBackroundColorScript(this.DataGrid0.ClientID);
}
/// <summary>
/// 注册根据发货地可用量是否小于等于0显示不同的底色的前端函数
/// </summary>
/// <param name="gridId"></param>
private void RegisterTdStoreBackroundColorScript(string gridId)
{
StringBuilder _script = new StringBuilder("<script language=\"javascript\">");
_script.Append(" if(!window.runStoreJudge) {");
_script.Append(" function runStoreJudge(){ ");
string mainBodyID = gridId + "_MainBody";
_script.AppendFormat(" var $mainTable = $('#{0} table');", mainBodyID);
_script.Append(" var $thead_tds = $mainTable.find('thead td');");
_script.Append(" var storeIdx = -1;");
_script.Append(" $.each($thead_tds, function(i, _td) { if($(_td).attr('data-ca') == '{\"fieldid\":\"Store\"}') { storeIdx = i; } });");
_script.Append(" var $tbody_trs = $mainTable.find('tbody tr');");
_script.Append(" var $tr, $storeTd, store = 0;");
_script.Append(" $.each($tbody_trs, function(_, tr) {");
_script.Append(" $tr = $(tr);");
_script.Append(" $storeTd = $tr.find('td:eq(' + storeIdx + ')');");
_script.Append(" store = +((+($storeTd.text().replace(/,/g, ''))).toFixed(8));");
_script.Append(" if(store<=0) { $tr.addClass('error_tr'); }");
_script.Append(" });");
_script.Append(" $.each($mainTable.find('tr.error_tr td'), function(_, td) { $(td).css('background', '#ffccc7'); });");
_script.Append(" };");
_script.Append(" }");
_script.AppendFormat("setTimeout(window.runStoreJudge, {0});", 200);
_script.Append(" </script>");
UFSoft.UBF.UI.AtlasHelper.RegisterAtlasStartupScript(this.Page, this.Page.GetType(), Guid.NewGuid().ToString(), _script.ToString(), false);
}
显示效果
评论 (0)