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

[Solved] Get all values of a column in Telerik Grid

1 Answer 241 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Priyanka C
Top achievements
Rank 1
Priyanka C asked on 19 Nov 2009, 10:03 PM
Hi ,

First of all thanks a lot for your last replies. It helped me a lot.Thanks a lot.

I need a solution for my grid.
I am using  new  Telerik.Web.UI  grid.

I am having grid with with few columns and a hyperlink as CommandItem for 'Add new record.'

<

 

CommandItemTemplate> <a href="#" onclick="return ShowInsertForm();">Add New Record</a 

 

</CommandItemTemplate>

ShowInsertForm()  is a javascript function where I am opening a displaying some messages using radwindow.

My requirement is :
I wanted to get all values of 'STATUS'  column from this Grid . column name is "Status".
This coulmn contains values 'O' or 'C'.
So I have to check all values of this colmn ,If they all are in 'C' status or in 'O' then on click of Add record hyperlink ShowInsertForm() JS function should fired where I have to show diffenet error messages for both status.

So Question is -   How to get all values from a grid column into a variables or array ?
and how to check whether value is 'C' or 'O' ?

is it possible to do all these into JAVASCRIPT and how ? Please help me regarding this as soon as possible.
Thanks in Advance.

REgards,
Priyanka

 

 

1 Answer, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 20 Nov 2009, 12:05 PM
Hi Priyanka,

Try the following client-side code in order to check the value in all the rows.

JavaScript:
 
<script type="text/javascript"
function ShowInsertForm() 
    var o = true
    var c = true
    var masterTable = $find("<%=RadGrid1.ClientID%>").get_masterTableView(); 
    for (var row = 0; row < masterTable.get_dataItems().length; row++) { 
        var item = masterTable.get_dataItems()[row]; 
        var cell = masterTable.getCellByColumnUniqueName(item, "Status"); 
        if(cell.innerHTML != "&nbsp;"
        { 
            o= false
            break;         
        } 
     } 
     for (var row = 0; row < masterTable.get_dataItems().length; row++) { 
        var item = masterTable.get_dataItems()[row]; 
        var cell = masterTable.getCellByColumnUniqueName(item, "Status"); 
        if(cell.innerHTML != 'C'
        { 
            c = false
            break;         
        } 
     } 
     if(c) 
     { 
        alert("All values are 'C'"); 
     } 
     if(o) 
     { 
        alert("All values are 'O'"); 
     } 
</script> 

Hope this helps,
Shinu.
Tags
Grid
Asked by
Priyanka C
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
Share this question
or