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

Show hidden row of grid from JavaScript

1 Answer 372 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Albert
Top achievements
Rank 1
Albert asked on 22 Jul 2010, 06:21 AM
Hello ,

I have initially bind 10 rows to rad grid and display only 3 rows to user, hide remaining rows from item databound event .

Now i have one button on out side grid [+] to add rows in grid .

What i want to do is when user click on add button, i want to show next hidden row by JavaScript .

Right now I call this function when user click on button .

function ShowRow()
   {        
       var grdDeparture=document.getElementById("<%=grdDeparture.ClientID%>"); 
       alert(grdDeparture);
//
var masterTableView = grdDeparture.MasterTableView; 
//above line not working , i cannot find MasterTableView here .
//Is there any reference that i have to add to access MasterTableView?
   } 

If any one know Please Help me .
Please send me code .
-Thanks

1 Answer, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 2
answered on 22 Jul 2010, 07:46 AM
Hello,

If you want to show the hidden rows using Java Script, you need to hide the rows from client side. You can hide the rows in 'OnRowCreated' event of grid.

ASPX:
<ClientSettings>
    <ClientEvents OnRowCreated="RowCreated"/>
</ClientSettings>

Java Script:
<script type="text/javascript">
    function RowCreated(sender, args)
      {
        var grid = sender;
        if (args._itemIndexHierarchical > 2)
          {
            var masterTableView = grid.get_masterTableView();
            masterTableView.get_dataItems()[args._itemIndexHierarchical - 1].set_visible(false);
          }
      }
</script>

ASPX:
<asp:Button ID="Button5" runat="server" OnClientClick="ShowRow(); return false;" Text="Show item" />

Java Script:
<script type="text/javascript">
 function ShowRow()
   {
        var grdDeparture = $find("<%=RadGrid1.ClientID %>");
        var masterTableView = grdDeparture.get_masterTableView();
        var count = masterTableView.get_dataItems().length;
        for (var i = 0; i < count; i++)
         {
            if (!masterTableView.get_dataItems()[i].get_visible())
             {
                 masterTableView.get_dataItems()[i].set_visible(true);
                 break;
            }
         }
    }
</script>

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