I am a newbie to jQuery and I posted a question a couple of days ago
and it was swiftyly answer.
The results of which helped me create a couple of functions which I am
posting.

Initially, I was searching for rows of a table with wildcard search
parameter.
Example: id*=\"IndividualsExisting" (notice the * )
This was taking a long time because the webpage has a few tabpages
with quite a few tables.
It took me awhile (as a newbie) and with the help of this group, I was
able to create
a couple of functions that used more specific Selector search criteria
and now the
searches go quite quickly.

Here are the functions and thanks to everyone for answering.
(Especially Charlie Griefer)

function jqSelectorStrTblRwObjSingle(p_i_How, p_s_pgPrg, p_s_Table_ID,
p_s_Row_ID, p_i_Row_Nbr) {
    // Descriptions : Returns a single Table Row Object jQuery
Selector String
    // p_i_How      : 1 or 2 - See switch case statements below
    // p_s_pgPrg    : In asp.Net user controls, the "ctl00_USER-
CONTROL_PATHNAME_Ctl_"  - If not using user-controls, leave "".
    // p_s_Table_ID : <table id=""  The id of the table
    // p_s_Row_ID   : <tr    id=""  The id of the table row
    // p_i_Row_Nbr  : If tablerow ID's are are incremented (i.e.
myRow1, myRow2, myRow3, etc) the exact row number looking for.
    // Usage
    //        var h1 = jqSelectorStrTblRwObjSingle(2,
"ctl00_MyUserControl_Ctl_", "MyTable", "myRow", 5) where 5 can be a
variable like iRowCount
    //        $(h1).each(function() {
    //            alert(this.id);
    //        });
    var retStr = "";
    switch (p_i_How) {
        case 1:
            // Example of what is returned:
            //    "table:first[id*=
\"tblucContactsIndividualsExisting_grd\"] tr:first[id*=
\"trMainucContactsIndividualsExisting_grd1\"]";
            // Returns single object
            // Contains Match of both Table & TR WITHOUT p_s_pgPrg***
for both
            retStr += "table:first[id*=\""
            retStr += p_s_Table_ID;
            retStr += "\"";
            retStr += "]";
            retStr += " tr:first[id*=";
            retStr += "\"";
            retStr += p_s_Row_ID;
            retStr += p_i_Row_Nbr;
            retStr += "\"";
            retStr += "]";
            break;
        case 2:
            // Example of what is returned:
            //   "table:first[id=
\"myUserControl_Ctl_tblucContactsIndividualsExisting_grd\"] tr:first
[id=\"myUserControl_Ctl_trMainucContactsIndividualsExisting_grd1\"]"
            //    table:first
[id="myUserControl_Ctl_tblucContactsIndividualsExisting_grd"] tr:first
[id="myUserControl_Ctl_trMainucContactsIndividualsExisting_grd1"]
            // Returns single object
            // Exact Match of both Table & TR WITH p_s_pgPrg*** for
both
            retStr += "table:first[id=\""
            retStr += p_s_pgPrg;
            retStr += p_s_Table_ID;
            retStr += "\"";
            retStr += "]";
            retStr += " tr:first[id=";
            retStr += "\"";
            retStr += p_s_pgPrg;
            retStr += p_s_Row_ID;
            retStr += p_i_Row_Nbr;
            retStr += "\"";
            retStr += "]";
            break;
        default:
            break;
    }
    //alert("retStr=" + retStr);
    return retStr;
}

function jqSelectorStrTblRwObjMulti(p_i_How, p_s_pgPrg, p_s_Table_ID,
p_s_Row_ID) {
    // Descriptions : Returns a MULTIPLE Table Rows Object jQuery
Selector String
    // p_i_How      : 1 or 2 - See switch case statements below
    // p_s_pgPrg    : In asp.Net user controls, the "ctl00_USER-
CONTROL_PATHNAME_Ctl_"  - If not using user-controls, leave "".
    // p_s_Table_ID : <table id=""  The id of the table
    // p_s_Row_ID   : <tr    id=""  The PARTIAL id of the table rows.
    //                              Since tablerow ID's are usually
incremented (i.e. myRow1, myRow2, myRow3, etc), just pass the "myRow"
without the number.
    // Usage
    //        var h1 = jqSelectorStrTblRwObjMulti(2,
"ctl00_MyUserControl_Ctl_", "MyTable", "myRow")
    //        $(h1).each(function() {
    //            alert(this.id);
    //        });
    var retStr = "";
    switch (p_i_How) {
        case 1:
            // Example of what is returned:
            //   "table:first[id=\"tblContactsGroupMembers\"] tr:[id*=
\"trMainucContactsGroupsMembers\"]";
            // Returns multiple object
            // Contains Match of both Table & TR WITHOUT p_s_pgPrg***
for both
            retStr += "table:first[id*=\""
            retStr += p_s_Table_ID;
            retStr += "\"";
            retStr += "]";
            retStr += " tr:[id*=";
            retStr += "\"";
            retStr += p_s_Row_ID;
            retStr += "\"";
            retStr += "]";
            break;
        case 2:
            // Example of what is returned:
            //   "table:first[id=
\"ctl00_ctl00_cph_MainContent_cph_gmbDiscuss_ucDiscuss_Edit_Ctl_ucContactsGroupsMembers_Ctl_tblContactsGroupMembers
\"] tr:[id*=
\"ctl00_ctl00_cph_MainContent_cph_gmbDiscuss_ucDiscuss_Edit_Ctl_ucContactsGroupsMembers_Ctl_trMainucContactsGroupsMembers
\"]";
            // Returns multiple object
            // Exact Match of both Table & TR WITH p_s_pgPrg*** for
both
            retStr += "table:first[id=\""
            retStr += p_s_pgPrg;
            retStr += p_s_Table_ID;
            retStr += "\"";
            retStr += "]";
            retStr += " tr:[id*=";
            retStr += "\"";
            retStr += p_s_pgPrg;
            retStr += p_s_Row_ID;
            retStr += "\"";
            retStr += "]";
            break;
        default:
            break;
    }
    //alert("retStr=" + retStr);
    return retStr;
}

Reply via email to