This question is locked. New answers and comments are not allowed.
On my razor view I have telerik Grid which will be populated with ajax call. What I want is that while the page is loading I want to show "Please wait, fetching data from the server... " message in the grid, which is actually working fine, but after the Grid action returned the data and if there is no data it still shows "Please wait, fetching data from the server..." instead I want to display "No record found".
I have tried to update the value of NoRecordsTemplate to "No record found" using client side script but it shows it for a second and return back to "Please wait, fet...." i.e the initial values that I gave it at design time. Is there any way that I can show the status by displaying "No record found" if there is no record.
Here is the view and the controller code, please if I make syntax error it must be typo
View
@(Html.Telerik().Grid<AAA.Model.Product>()
.NoRecordsTemplate("Please wait, fetching data from the server...")
.Name("gProductList")
.DataKeys(key => key.Add(T => T.ProductID))
.ToolBar(commands => commands.Insert())
.DataBinding(dataBinding =>
{
dataBinding.Ajax()
.Select("List", "Product")
.Update("_Update", "Product")
.Insert("_Insert", "Product");
})
.Columns(columns =>
{
columns.Command(commands =>
{
commands.Edit().ButtonType(GridButtonType.ImageAndText);
}).Width(200);
columns.Bound(T => T.ProductName).Width(260);
columns.Bound(T => T.Release).Width(150);
})
<script type="text/javascript">
$(document).ready(function () {
$('#gProductList').find('.t-no-data td').text('No record found.');
})
</script>
Controller
[GridAction]
public ActionResult List()
{
AAAContext context = new AAAContext();
var model = context.GetAllProducts();
return View(new GridModel<Product>
{
Data = model
});
}
Also the same thing happening for renaming the Add New Record button text, first it shows "Add New Record" then shows my script value
$(document).ready(function () {
$(".t-grid-add").text('Add New Product');
})
I have tried to update the value of NoRecordsTemplate to "No record found" using client side script but it shows it for a second and return back to "Please wait, fet...." i.e the initial values that I gave it at design time. Is there any way that I can show the status by displaying "No record found" if there is no record.
Here is the view and the controller code, please if I make syntax error it must be typo
View
@(Html.Telerik().Grid<AAA.Model.Product>()
.NoRecordsTemplate("Please wait, fetching data from the server...")
.Name("gProductList")
.DataKeys(key => key.Add(T => T.ProductID))
.ToolBar(commands => commands.Insert())
.DataBinding(dataBinding =>
{
dataBinding.Ajax()
.Select("List", "Product")
.Update("_Update", "Product")
.Insert("_Insert", "Product");
})
.Columns(columns =>
{
columns.Command(commands =>
{
commands.Edit().ButtonType(GridButtonType.ImageAndText);
}).Width(200);
columns.Bound(T => T.ProductName).Width(260);
columns.Bound(T => T.Release).Width(150);
})
<script type="text/javascript">
$(document).ready(function () {
$('#gProductList').find('.t-no-data td').text('No record found.');
})
</script>
Controller
[GridAction]
public ActionResult List()
{
AAAContext context = new AAAContext();
var model = context.GetAllProducts();
return View(new GridModel<Product>
{
Data = model
});
}
Also the same thing happening for renaming the Add New Record button text, first it shows "Add New Record" then shows my script value
$(document).ready(function () {
$(".t-grid-add").text('Add New Product');
})
