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

get_masterTableView() problem

6 Answers 250 Views
Grid
This is a migrated thread and some comments may be shown as answers.
SeRiAlKiL
Top achievements
Rank 1
SeRiAlKiL asked on 05 Sep 2008, 02:03 PM
Hello,

I am trying to use this example for a bunisess solution
http://www.telerik.com/help/aspnet-ajax/client-update-insert-delete.html

I am using the last version of RadControls for ASP.NET AJAX

Anywhere in the javascript code where i call

var tableView = $find("<%= RadGrid1.ClientID %>").get_masterTableView();

I recive null and nothing seems working

Any clue about this problem?

6 Answers, 1 is accepted

Sort by
0
Vlad
Telerik team
answered on 05 Sep 2008, 02:08 PM
Hello SeRiAlKiL,

Please attach an event handler for OnCommand client-side event similar to this example:
http://demos.telerik.com/aspnet/Prometheus/Grid/Examples/Client/LiveData/DefaultCS.aspx

Best wishes,
Vlad
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
SeRiAlKiL
Top achievements
Rank 1
answered on 05 Sep 2008, 03:17 PM
Really thank now it's working

I have only a problem, when i click the save button and the datagrid is repainted by 

var

grid = $find("<%= RadGrid1.ClientID %>");
grid.repaint();


The column having the datetime is changing from "04/01/2008" to "Tue Apr 1 00:00:00 UTC+0200 2008"

It seem that the dataformat is not working after a client repaint, there is a solution for this? Thanks again

0
Nikolay Rusev
Telerik team
answered on 08 Sep 2008, 09:09 AM
Hi SeRiAlKiL,

I suggest you to try using this code snippet instead
function updateGrid(result)  
{  
  //fix date format  
  for (var i = 0; i < result.length; i++)   
  {  
    result[i].BirthDate = String.format("{0:MM/dd/yyyy}", result[i].BirthDate)  
  }   
 
  var tableView = $find("<%= RadGrid1.ClientID %>").get_masterTableView();  
  tableView.set_dataSource(result);  
  tableView.dataBind();    



All the best,
Nikolay
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
SeRiAlKiL
Top achievements
Rank 1
answered on 08 Sep 2008, 09:18 AM
That made the trik, thanks

Now i am trying to improve the example

I am in the case where there are no items in the collection, and i want to add a new one

Everything is working except one single thing

When i load the project and there are no records in the collection, the grid have a single row with "No records to display." into it

When i switch to "add employee" tab and i press "save", my code correctly add a new employee to the collection, and then the "updateGrid" method is called

The grid is updated and i can see the row i added, but the "No records to display." row is still there, and i cannot find a way to remove that line

Can you give me an advice?

Really thanks
0
Nikolay Rusev
Telerik team
answered on 10 Sep 2008, 12:25 PM
Hello SeRiAlKiL,

You can try the following code to remove the "No records to display" row just before the grid is bound:

var tableView = $find("<%= RadGrid1.ClientID %>").get_masterTableView();                  
if (tableView.get_dataItems().length == 0)  
   tableView.get_element().tBodies[0].rows[0].innerHTML = ""

Other possible solution is to set empty NoRecordsTemplate.
<NoRecordsTemplate></NoRecordsTemplate

Kind regards,
Nikolay
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
SeRiAlKiL
Top achievements
Rank 1
answered on 10 Sep 2008, 12:42 PM
Thanks for your reply

I experimented a bit and solved using the following code

var table = $find("<%= RadGrid1.ClientID %>").get_masterTableView().get_element();  
table.deleteRow(1); 

But changed to the empty NoRecordsTemplate and it's a better solution

Thanks again
Tags
Grid
Asked by
SeRiAlKiL
Top achievements
Rank 1
Answers by
Vlad
Telerik team
SeRiAlKiL
Top achievements
Rank 1
Nikolay Rusev
Telerik team
Share this question
or