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

problem setting radgrid with empty datasource on radtextbox "OnFocus" event...

1 Answer 55 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Dan
Top achievements
Rank 1
Dan asked on 25 Apr 2017, 02:12 PM

I'm having difficulty finding a way to accomplish what I want to do.

My Webform has the following controls on it:

1.  RadTextBox

2.  RadButton

3.  RadGrid

Very simple.   The user is prompted (RadTextBox) to enter the first letters of the customer name that they would like to view (RadGrid).  When they click on the view button (RadButton), the code behind executes in button click event to query the data and executes a .Rebind to refresh the RadGrid.  That all works very well.  My problem is that I'm trying to find a way to empty the RadGrid datasource when the user clicks back into the RadTextBox and it receives focus.  I found a few lines of Javascript in another post on the Telerik forms.   

Here is the script:

            var masterTable = $find("<%= RadGrid_CustData.ClientID %>").get_masterTableView();
            masterTable.set_dataSource([]);
            masterTable.dataBind();

I am able to execute this javascript code from a client-side button click event, but it fails when I try to execute it from the RadTextBox OnFocus client event.   

Does anyone have any ideas on how I can accomplish this ?

 

Thank you

 

 

     

1 Answer, 1 is accepted

Sort by
0
Peter Milchev
Telerik team
answered on 28 Apr 2017, 08:35 AM
Hello DB,

We have already answered in your support thread and we will paste the solution here for convenience and better visibility from the community.

Setting the data source to an empty array is valid approach only if the grid is bound client-side.

For server-side binding, you can call the rebind method of the master table as suggested in the Invoke a RadGrid rebind from JavaScript forum thread. 

Attached is a sample project that implements the suggested solution.

Regards,
Peter Milchev
Telerik by Progress
Try our brand new, jQuery-free Angular 2 components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
Tags
Grid
Asked by
Dan
Top achievements
Rank 1
Answers by
Peter Milchev
Telerik team
Share this question
or