OK、投稿直後に思いついたアイデアは、私が使用したものになりました。これは、shoebox639 が提案したものでもあります。必要な clientID をヘルパー メソッドに引き出すコードを追加しました。
//****************************************************************************************
//* Find a requested control's clientID as the first parm passed in from a string
//* passed in as the second parm.
//****************************************************************************************
function locateClientID(requestedClientID, HTML_StringToSearch) {
var returnValue = "";
//If we have something to search for and something to search in, do so. Null or "" will fail this check.
if (requestedClientID && HTML_StringToSearch) {
//Find the starting point of the string starting with "id=", then any number of other letters, numbers,
// or underscores, then ending in the specified "requestedClientID" parm value. We add three to offset
// the "id+" part of the search string, which we don't want in the results, but include to locate value.
var startingPoint = HTML_StringToSearch.search("id=[a-z0-9A-Z_]*" + requestedClientID) + 3;
//If we found a valid starting point, i.e. NOT -1, then continue processing the string.
if (startingPoint > -1) {
//Now that we know where our clientID for the requested control starts in the passed in string,
// find the ending " " so we know how much to substr off to pull out the requested client id.
var endingPoint = HTML_StringToSearch.indexOf(" ", startingPoint);
//The endingPoint could be -1 if there is no space after the "id" property, but all the examples
// I have seen have more attributes after.
//substr out the clientID and return it to the caller.
returnValue = HTML_StringToSearch.substr(startingPoint, (endingPoint - startingPoint));
}
}
return returnValue;
}
//*****************************************************************************************
したがって、私の場合、rcb123 を最初のパラメーターとして渡し、innerHTML 文字列 blob を 2 番目の値として渡すと、関数は clientID 値を返します。clientID を取得したら、それを使用して別の jQuery メソッド呼び出しを実行します。
function cv123_Validate(sender, eventArgs) {
//Get a ref to the radGrid's collection of rows.
var gvRadGridNameRows = $find("<%= gvRadGridName.ClientID %>").MasterTableView.get_dataItems();
var innerHTML;
var foundClientID;
var errorImage;
var rcb123;
//Process every row in the radGrid.
for (var row = 0; row < gvRadGridNameRows.length; row++){
//Get the cell in question's innerHTML value.
innerHTML = gvRadGridNameRows.get_cell("uniqueCellName").innerHTML;
//Get ref to the 'error image'.
errorImage = $("#" + locateClientID("imgHUDError", innerHTML));
//locate the unique clientID of the rcb123 in this row.
foundClientID = locateClientID("rcb123", innerHTML);
//Use the found unique clientID with jQuery to get a ref to the dropdown list.
rcb123 = $("#" + foundClientID)[0];
//If the dropdown list's selected index is 0 or less AND the control is NOT
// disabled, active the single error message tied to this custom validator
// and show the 'error image' next to the control.
if (rcb123.selectedIndex < 1 && rcb123.isDisabled != true) {
errorImage.css("height", 12);
eventArgs.IsValid = false;
}
else //Otherwise, hide the error image.
{
errorImage.css("height", 0);
}
}
}
私はまださまざまな例をテストしており、記載されている以外の穴を探していますが、私の目的ではこれでうまくいきます。ヘルパー ルーチンを作成したのは、innerHTML ブロブでも画像を操作するためです。
アイデアは、グリッド内の各コントロールの横に「エラー画像」を配置して、エラーが発生した場所を視覚的に参照できるようにすることでしたが、単純に埋め込むときに得た X の繰り返しエラー メッセージの代わりに、1 つのエラー メッセージのみを errorSummary コントロールに追加します。ドロップダウン リストの横にある必須フィールド バリデータ。(私のBAグループはそれが気に入らなかった...)
これが誰かを助けることを願っています。