I need to update the data-title="Status"
value in a table.
For example, if the data-status text is "DataSubmission", it should be changed to 'Inprogress'
Here's the code snippet:
$("#cpC_gvSearchResult tr td:contains('DataSubmission')").html("In Progress");
If the data-title="Status" text value is empty or blank, we want to change it to 'Available'
$("#cpC_gvSearchResult tr td:contains('')").html("Available");
This is the code for the table:
<table class="inbox appList" cellspacing="0" data-openonpick="False" id="cpC_gvSearchResult" style="border-collapse:collapse;">
<thead>
<tr class="inboxHeader">
<th data-field="ApplicationId" scope="col"> Id</th>
<th data-field="ApplicantFirstName" scope="col">First Name</th>
<th data-field="CurrentQueue" scope="col">Status</th>
</tr>
</thead>
<tbody>
<tr class="inboxRow closedApp">
<td class="inboxCol" data-title="Application Id">1</td>
<td class="inboxCol" data-title="Entity / Individual First Name" data-sid="al_Cust05">Dummy Name</td>
<td class="inboxCol" data-title="Status" data-sid="al_ApplicantFirstName">DataSubmission</td>
</tr>
<tr class="inboxAltRow closedApp">
<td class="inboxCol" data-title="Application Id">2</td>
<td class="inboxCol" data-title="Entity / Individual First Name" data-sid="al_Cust05">Dummy Name</td>
<td class="inboxCol" data-title="Status" data-sid="al_ApplicantFirstName"> </td>
</tr>
<tr class="inboxRow closedApp">
<td class="inboxCol" data-title="Application Id">3</td>
<td class="inboxCol" data-title="Entity / Individual First Name" data-sid="al_Cust05">Dummy Name</td>
<td class="inboxCol" data-title="Status" data-sid="al_ApplicantFirstName">DataSubmission</td>
</tr>
<tr class="inboxAltRow closedApp">
<td class="inboxCol" data-title="Application Id">4</td>
<td class="inboxCol" data-title="Entity / Individual First Name" data-sid="al_Cust05">Dummy Name</td>
<td class="inboxCol" data-title="Status" data-sid="al_ApplicantFirstName"> </td>
</tr>
</tbody>
</table>
Jquery script:
var rowCount = $("#cpC_gvSearchResult tr").length;
alert(rowCount);
for(var i = 1; i < rowCount; i++)
{
var status = $("#cpC_gvSearchResult tr").find("td:eq(3)").text();
if(status =="DataSubmission" )
{
$("#cpC_gvSearchResult tr td:contains('DataSubmission')").html("In Progress");
}
else
{
$("#cpC_gvSearchResult tr td:contains('')").html("Available");
}
}
View the live demo here