This is a migrated thread and some comments may be shown as answers.

[Solved] NoRecordsTemplate

2 Answers 186 Views
Grid
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Yordanos
Top achievements
Rank 1
Yordanos asked on 19 Jan 2012, 08:03 PM
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');
})

2 Answers, 1 is accepted

Sort by
0
Accepted
Dimo
Telerik team
answered on 20 Jan 2012, 09:52 AM
Hi Yordanos,

The described behavior has been discussed at

http://www.telerik.com/community/forums/aspnet-mvc/grid/changing-wording-no-records-to-display.aspx

http://www.telerik.com/community/forums/aspnet-mvc/grid/grid-message-no-records.aspx

All the best,
Dimo
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
Yordanos
Top achievements
Rank 1
answered on 20 Jan 2012, 02:53 PM
Hi Dimo,

Thanks for the quick replay.

Yes putting my js $('#gProductList').find('.t-no-data td').text('No record found.') in the grid client even OnDataBound works perfect.


Thanks,
Yordanos
Tags
Grid
Asked by
Yordanos
Top achievements
Rank 1
Answers by
Dimo
Telerik team
Yordanos
Top achievements
Rank 1
Share this question
or