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

Get Value in the Column

3 Answers 48 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Atchut
Top achievements
Rank 1
Atchut asked on 01 Aug 2012, 01:12 AM
Hello,

I am trying to get the value of the column in RadGrid. Below is my code. It is working Perfectly fine.

 var satype = tableView.getCellByColumnUniqueName(objRows[nCurrentIndex], "ExpirationDate")
  var annual = satype.innerText;

My Issue is, when the cell value is nothing, it is getting me the next cell Value even though Next column uniquename is different from Expiration date. I want to disable the textbox, if there is no value in the column.

How an I get this ?

3 Answers, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 01 Aug 2012, 05:49 AM
Hi,

I suppose you want to disable a TextBox in the TemplateColumn when a cell value is nothing.

Javascript:
<script type="text/javascript">
    function pageLoad()
     {
        var grid = $find("<%=RadGrid1.ClientID%>");
        var rows = grid.get_masterTableView().get_dataItems();
        for (var i = 0; i < rows.length; i++)
        {
            var satype = rows[i].get_cell("UniqueName").innerHTML;
            if (satype == "&nbsp;") {
                var textbox = rows[i].findElement("Texbox1"); //TextBox in Itemtemplate of TemplateColumn
                textbox.disabled = true;
            }       
        }
    }
</script>

Thanks,
Shinu.
0
Atchut
Top achievements
Rank 1
answered on 01 Aug 2012, 12:40 PM
Hello,

Thanks for your response.

THe same thing happening for the below line of code. If the column is blank, it is getting the next column value.

var satype = rows[i].get_cell("UniqueName").innerHTML; 

THanks
0
Shinu
Top achievements
Rank 2
answered on 02 Aug 2012, 05:59 AM
Hi Atchut,

Unfortunately i couldn't replicate the issue.Here is the sample code snippet I tried.

ASPX:
<telerik:RadGrid ID="RadGrid1" runat="server" AllowFilteringByColumn="True" AutoGenerateColumns="False"
DataSourceID="SqlDataSource1">
    <MasterTableView>
            <Columns>
                <telerik:GridBoundColumn DataField="ShipVia" HeaderText="ID" UniqueName="ShipVia" ></telerik:GridBoundColumn>
                <telerik:GridBoundColumn DataField="OrderID" HeaderText="Company" UniqueName="OrderID"></telerik:GridBoundColumn>
                <telerik:GridTemplateColumn>
                    <ItemTemplate>
                        <asp:TextBox ID="Texbox1" runat="server"></asp:TextBox>
                    </ItemTemplate>
                </telerik:GridTemplateColumn>
            </Columns>
    </MasterTableView>
</telerik:RadGrid>

Javascript:
<script type="text/javascript">
    function pageLoad()
     {
        var grid = $find("<%=RadGrid1.ClientID%>");
        var rows = grid.get_masterTableView().get_dataItems();
        for (var i = 0; i < rows.length; i++)
        {debugger
            var satype = rows[i].get_cell("ShipVia").innerHTML;
            if (satype == " ") {
                var textbox = rows[i].findElement("Texbox1");
                textbox.disabled = true;
            }       
        }
    }
</script>

Please provide the code if it doesn't help.


Thanks,
Shinu.
Tags
Grid
Asked by
Atchut
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
Atchut
Top achievements
Rank 1
Share this question
or