3 Answers, 1 is accepted
0
Accepted
Hi Robert,
You can use the following statement in your code to get the number of rows:
All the best,
Petur Subev
the Telerik team
You can use the following statement in your code to get the number of rows:
$(
'#Grid'
).data(
'tGrid'
).data.length
All the best,
Petur Subev
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the Telerik Extensions for ASP.MET MVC, subscribe to their blog feed now.
0
Robert
Top achievements
Rank 1
answered on 29 Feb 2012, 05:52 PM
Thanks Petur. I must still be doing something wrong.
I have this script that should fire on the OnComplete event. The goal is to hide the Add toolbar button when the number of items in the grid is == the total # of available items that can be added. But when I run it, the grid doesn't load any records. If I hard-code a # in, it works, but when I try to use the grid record count using the tip you gave me, they don't.
I have this script that should fire on the OnComplete event. The goal is to hide the Add toolbar button when the number of items in the grid is == the total # of available items that can be added. But when I run it, the grid doesn't load any records. If I hard-code a # in, it works, but when I try to use the grid record count using the tip you gave me, they don't.
@section HeadContent {
<script type=
"text/javascript"
>
function
grid_loaded(args) {
if
(
"@ViewBag.TotalRoles"
== $(
'#Roles'
).data(
'tGrid'
).data.length) {
$(
'.t-grid-add'
).hide();
}
else
{
$(
'.t-grid-add'
).show();
}
};
</script>
0
Robert
Top achievements
Rank 1
answered on 29 Feb 2012, 06:19 PM
I can be such a noob sometimes. Can you tell I am not a javascript programmer? Corrected version below - and it works. The only quibble I have is that instead of getting a count of all rows coming back in the AJAX select, I am only getting the number actually displayed/paged.
For now I will work around that by turning paging off on this particular grid.
For now I will work around that by turning paging off on this particular grid.
<
script
type
=
"text/javascript"
>
function grid_loaded(e) {
var noOfRecords = $(this).data('tGrid').data.length;
if ("123" == noOfRecords) {
$('.t-grid-add').hide();
} else {
$('.t-grid-add').show();
}
};
</
script
>