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

Client Side Event Corresponding With NoRecordsTemplate?

3 Answers 26 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Karrie
Top achievements
Rank 1
Karrie asked on 01 Oct 2014, 03:29 PM
I need to run some light JavaScript when the NoRecordsTemplate kicks in for a RadGrid (when there are no records in the DataSource) anywhere across a web application.


Since I didn't find an analogous client side API method built in for this, I thought this would still be pretty easy by using the OnGridCreating event handler to add a function that runs later (following page load) & includes a conditional that checks for data items or something similar.


Surprisingly, I'm finding the OnGridCreating event is not firing when the NoRecordsTemplate kicks in when hooked up via the grids' ClientSettings.  Should it?  (Note : when the NoRecordsTemplate does not kick in the OnGridCreating 
get fired as expected & function runs normally/as expected)

I can understand why OnGridCreated possibly wouldn't fire in a no records situation, but it seems like OnGridCreating should fire regardless of if the grid ends up having records or no records.

I'm also open to other approaches if this turns out to be a 'working as designed not as desired' situation.

3 Answers, 1 is accepted

Sort by
0
Viktor Tachev
Telerik team
answered on 06 Oct 2014, 11:54 AM
Hi Karrie,

The behavior you describe can be observed if the DataSource property of RadGrid is null. Try to assign an empty object to DataSource and both GridCreating and GridCreated events should be fired.

I am attaching a sample project as illustration. It works as expected on my end. Give it a try and let me know how it works for you.

Regards,
Viktor Tachev
Telerik
 

Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

 
0
Karrie
Top achievements
Rank 1
answered on 06 Oct 2014, 05:01 PM

The sample project does not use a NoRecordsTemplate which is the crux of the issue.  Are you sure you were able to successfully trigger the OnGridCreating event when a NoRecordsTemplate was specified ?

I still do not see the expected eventing behavior regardless of whether the DataSource is assigned null or empty object.
0
Viktor Tachev
Telerik team
answered on 09 Oct 2014, 09:53 AM
Hi Karrie,

The NoRecordsTemplate should not affect the behavior. Would you check the browser console when running your project and ensure that there are no JavaScript errors on the page?

This said, I added NoRecordsTemplate to the sample and the events are still triggered as expected on my end. I am attaching the project as reference. Try running the sample and let me know if it works on your end as well.

I would appreciate it if you let me know what needs to be changed in the sample in order to replicate the issue.

Regards,
Viktor Tachev
Telerik
 

Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

 
Tags
Grid
Asked by
Karrie
Top achievements
Rank 1
Answers by
Viktor Tachev
Telerik team
Karrie
Top achievements
Rank 1
Share this question
or