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

Is it possible to Update say a label control in a row and column from Javascript,.?..if so how please

5 Answers 82 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Neal
Top achievements
Rank 1
Neal asked on 04 Aug 2010, 12:14 PM
I need to update the value in a row and column of a Label in radgrid with a value I have from Javascript.
The value is a return arrg from a popup radwindow.

Is it possible and if so how please.

Thx
Neal

5 Answers, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 04 Aug 2010, 01:40 PM
Hello Neal ,


Access the corresponding dataItem from client-side and then use the findElement() method to get reference to the Label control in ItemTemplate.

Client Code:
<script type="text/javascript"
 function getLabel() { 
        var grid = $find("<%= RadGrid1.ClientID %>"); 
        var masterTableview = grid.get_masterTableView(); 
        var firstDataItems = masterTableview.get_dataItems()[0]; 
        var labelControl= dataitems[i].findElement("Label1"); 
    }        
</script>


Go through the following link to know more:
findElement()


-Shinu.
0
Neal
Top achievements
Rank 1
answered on 04 Aug 2010, 04:59 PM
Thx Shinu

One Q tho re that,...the "i" in
var labelControl= dataitems[i].findElement("Label1"); 

do i suppose that is the 0th based position of the control in the dataitems

i.e lets say i have a checkbox and a label and 2 textboxes (both of which I want to populate from the args retrieved.
Is the "i" then the position of each say 0=label1, 1= label2 2= label3 etc?

(Thereafter I do a postback, such that i can use those vals for calcs in the grid)
but my postback eventargs (in Page_Load) seem not to have ameans of identifying what the event args are. ..kinda restricted to ToString() e.HashCode e.Equals and e.GetType.

So I guess there is a 2nd question .. Where how do I trap in code behind that there is a postback with event args specifically for that forced postbacl

I have a radajaxmanger on the page,...could the ajax partial postback request be of help? 

Thx
Neal
0
Neal
Top achievements
Rank 1
answered on 05 Aug 2010, 12:39 PM
Hi,

I am having no success with retrieving rows (client side) of my radgrid.(which is open and populated and has some 14 rows of data in it (version 2009.2)

I tried the following, using "Alerts" to determine how far it went, and have notated them as successful or not successful.
Any help would be appreciated
 thanks
Neal

 

var masterTableView;

 

 

var grid = $find("<%= grvCoverelements.ClientID %>");

 

 

if (grid)

 

{

masterTableView = grid.get_masterTableView();

 

// alert ("have grid "); //Succesful

 

}

 

 

if (masterTableView)

 

{

alert(

"have masterTableview " ); ////Succesful

 

alert(masterTableView.Rows.length);

//NOT successful

 

 

 

for (var i=0; i < masterTableView.Rows.length; i++)

 

{

alert(

"looping" ); //NOT successful

 

 

var cell = masterTableView.GetCellByColumnUniqueName(masterTableView.Rows[i] , "ORateCBX")

 




and

// var firstDataItems = masterTableView.get_dataItems();

// if (firstDataItems)

// {

// length = firstDataItems.length;

// alert("have length = " + length);

// }

//

// if (masterTableview)

// {

// alert("have masterTableview " );

// if (length > 0)

// {

// for (var i = 0; i < length; i++)

// {

// alert("in for loop" );  //NOT SUCCESSFUL

// var dataItem = dataitems[i].findElement("txtORate");

// if (dataItem)

// {

// // 1. Get the rate textbox

// alert(i);

// var txtRate = dataitems[10].findElement("txtORate");

// alert("rate is " + txtRate)

// }

// }

// }

 

0
Maria Ilieva
Telerik team
answered on 09 Aug 2010, 09:22 AM
Hello Neal,


Note that RadGrid is by design bound control. The ASP.NET platform does not allow editing a database with JavaScript on the client. Therefore the RadGrid could not be updated only on the client without hitting the server as this does not make any sense. Modifying a row only on the client-side without a hit on the server is kind of html injection and it does not correspond with the RadGrid main functionality. The new rows will not be able to handle the main grid functionalities like sorting, paging, filtering etc. 


Regards,
Maria Ilieva
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
Neal
Top achievements
Rank 1
answered on 10 Aug 2010, 01:29 PM
Hi and thanks, but Princy did give me the js to accomplish what i needed, i.e. insert values I retrieved as args from a radwindow popup, into the Textboxes in the correct col and row (I added a quick condition for that), and force a postback and allow server side code to use those and do the calculations i needed.

Neal
Tags
Grid
Asked by
Neal
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
Neal
Top achievements
Rank 1
Maria Ilieva
Telerik team
Share this question
or