Nice article, one question though, if I get zero hits and use the set_virtualItemCount(0) the grid does not show that there are zero hits, do I maybey need to call an update or refresh method on the grid?
Thanks
4 Answers, 1 is accepted
Generally if you return empty collection the grid should handle this automatically. I notice unfortunately that NoRecordsTemplate/NoMasterRecordsText does not work properly in this case and we have fixed this immediately. The fix will be available next week with our service pack.
Best wishes,
Vlad
the Telerik team
Check out Telerik Trainer, the state of the art learning tool for Telerik products.
Kind of a hack but I just manipulated the Table in javascript to show no results:
Something like:
var myTable = document.getElementById("ctl00_ContentPlaceHolder1_RadGrid1_ctl00");
myTable.deleteRow(1);
myTable.deleteTFoot();
var newrow = myTable.insertRow(1) //add new row to end of table
newrow.height = "30";
var newcell_0 = newrow.insertCell(0) //insert new cell to row
newcell_0.align = "right";
newcell_0.innerHTML = "<b>No </b>";
var newcell_1 = newrow.insertCell(1);
newcell_1.innerHTML = "<b>records found.</b>";
Hi Vlad,
I downloaded the latest service pack and I still can't get the grid to show zero hits, I am using your exmple.
Thanks
Chris
You can use the following code to hide grid data items if there are no records to display.
/listen for OnDataBound client event/
<ClientEvents OnDataBound="Grid_DataBound" /> |
/code for the handler/
<script type="text/javascript"> |
function Grid_DataBound(sender, args) |
{ |
if ($telerik.$(".rgNoRecords", sender.get_masterTableView().get_element()) |
.css("display") != "none") |
{ |
$telerik.$(".GridRow_Office2007", sender.get_masterTableView().get_element()) |
.css("display", "none"); |
$telerik.$(".GridAltRow_Office2007", sender.get_masterTableView().get_element()) |
.css("display", "none"); |
} |
} |
</script> |
Kind regards,
Nikolay
the Telerik team
Check out Telerik Trainer, the state of the art learning tool for Telerik products.