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

[Solved] Rad grid client side

5 Answers 218 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Mohammad Insairat
Top achievements
Rank 1
Mohammad Insairat asked on 20 Aug 2009, 07:20 AM
Hello
could you please show any example how to work with radgrid client side events
how to insert new item using masterTable.insertItem(obj) then rebind the grid.
update and delete operation client side without using web methods
i've been trying to insert new item for too long now, the methods works fine without throwing any exception, but nothing added to the grid.


Thanks in advanced

5 Answers, 1 is accepted

Sort by
0
Mira
Telerik team
answered on 20 Aug 2009, 02:20 PM
Hello Mohammad,

I suggest that you take a look at the following online resources:

Client-side update/insert/delete help topic

Client-side update/insert/delete demo

Let me know whether they helped you.

Kind regards,
Mira
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
0
Mohammad Insairat
Top achievements
Rank 1
answered on 20 Aug 2009, 03:53 PM
Thanks Mira,
but both links you have sent using WebMethod to insert or update.
i wonder if i can Insert new item using javascript
Well, below is a sample code, if you could check it that would be great.

//JSON 

var

 

taxpayerEmployment =

 

{

Employer:

null,

 

StartDate:

null,

 

EndDate:

null,

 

Notes:

null,

 

create:

function() {

 

 

var obj = new Object();

 

obj.StartDate =

"";

 

obj.EndDate =

"";

 

obj.Notes =

"";

 

obj.Employer =

"";

 

 

return obj;

 

}

};

 

var Employer =

 

{

Tin:

null,

 

Name:

null,

 

Type:

null,

 

Authority:

null,

 

create:

function() {

 

 

var employerObj = new Object();

 

employerObj.Tin =

'';

 

employerObj.Name =

'';

 

employerObj.Type =

'';

 

employerObj.Authority =

'';

 

 

return employerObj;

 

}

}
The am trying to insert new item

 

function

 

AddNewItem() {

 

TaxpayerEmployment.create();

TaxpayerEmployment.Id =

'1';

 

TaxpayerEmployment.Name =

'TestName';

 

TaxpayerEmployment.StartDate =

'';

 

TaxpayerEmployment.EndDate =

'';

 

TaxpayerEmployment.Type =

'Employee';

 

 

var masterTable = $find("<%= grdWorkPlace.ClientID %>").get_masterTableView();

 

masterTable.insertItem(TaxpayerEmployment);

masterTable.showInsertItem(

true);

When i run the code, i got no exceptions but at the same time, nothing is added to the gird!
is it doable? if yes what am missing

Thanks in advanced

 

0
Mira
Telerik team
answered on 21 Aug 2009, 03:06 PM
Hi Mohammad,

Thank you for getting back to us.

I am afraid that what you are trying to achieve is not that easy - when your grid is databound client-side, you should insert the new records through an external form and rebind the grid as it is shown in the Client-side update/insert/delete help topic.

Kind regards,
Mira
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
0
Mohammad Insairat
Top achievements
Rank 1
answered on 21 Aug 2009, 04:13 PM
Hello Mira
Thanks for your reply, still not clear about it.
again the link u've sent using Webmethod to get the collection and then rebind the grid.

What am trying to do, is to add new items using javascript not using Web methods. is it doable?

its something like
after getting the id for the master table
i wanna use the Insertitem method then to load it into the gird. (javascript)

Thanks again in advanced.



0
Mira
Telerik team
answered on 26 Aug 2009, 02:46 PM
Hello Mohammad,

The code snippets you sent in your previous post looks fine to me, but as I said you should use external form to insert records in client-side bound grid and rebind the grid using its client-side rebind() method after insertion. You could not use the built-in edit forms, be it either auto-generated ot templated ones with client-side bound grid as they require postback to open and close.
Please note that no matter how is the grid bound, with WebMethos, PageMethods or Declarative binding,
 in order the changes/insertion to take effect, the grid should be rebound.

Kind regards,
Mira
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
Tags
Grid
Asked by
Mohammad Insairat
Top achievements
Rank 1
Answers by
Mira
Telerik team
Mohammad Insairat
Top achievements
Rank 1
Share this question
or