I'm using Telerik's Kendo suite and I need to perform a check on each cell in the Scheduler widget. I do this by searching for an attribute called 'role' and doing an .each on them. This works fine, but if I have multiple schedulers on the page I don't want to iterate over all td's...just ones in a specific scheduler (which is an html table under the hood). I tried giving the scheduler an ID, but the selector doesn't seem to find any td's. When I just use ("td[role=gridcell]").each it works but comes back with all td's in the page. If I try adding the id of the scheduler I want, it comes back with nothing.
var scheduler = $("#scheduler").data("kendoScheduler");
var view = scheduler.view();
view.table.find("#scheduler td[role=gridcell]").each(function (index, value)
{
// Do checking here.
})
I'm sure there's an issue with my syntax in the selector but I can't figure it out.
There is no need for the #scheduler
selector in the find
call.
$("#scheduler").find("td[role=gridcell]").each(function (index, value) { $(value).css('color', 'red'); });
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> <table id="scheduler"> <tr> <td role="gridcell">A</td> <td role="gridcell">B</td> <td>C</td> <td>D</td> </tr> </table> <table id="test"> <tr> <td role="gridcell">A</td> <td role="gridcell">B</td> <td>C</td> <td>D</td> </tr> </table>
In jQuery, you should just be able to do this:
$("#scheduler td[role='gridcell']").each(function(index, elem) {
// code here
});
Note: There is no need to use a separate .find()
operation as you can just put it all into the selector.
See demo: http://jsfiddle.net/jfriend00/49Lg411h/
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.