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

how to hide row in radgrid?

3 Answers 520 Views
Grid
This is a migrated thread and some comments may be shown as answers.
hamda
Top achievements
Rank 1
hamda asked on 12 Apr 2010, 07:43 AM
hi there...
can someone help me? am trying to find a way to hide one whole row  data field from a radgrid of aspecific Id inside  C#  programming code?

I don't want the user to see the row once he click on (delete) button , but in real the data still there in the database but the (active) field has been updated to = 0....

thanx..

3 Answers, 1 is accepted

Sort by
0
hamda
Top achievements
Rank 1
answered on 12 Apr 2010, 08:28 AM
thanx...
I think I found the solution :s

all what I needed to do was to set the defult value for the (active) field in the data source to =1
then the grid will never bind a row with active= 0
:

fast ....isn't ?... :D

bye

0
maysa
Top achievements
Rank 1
answered on 28 Apr 2011, 11:42 AM
hi

may i have your result

i was looking how to hid the row if the active is = 1 so to hidden and not delete


thank you
0
Shinu
Top achievements
Rank 2
answered on 28 Apr 2011, 12:51 PM
Hello Maysa,

You can achieve this either from client side or server side.

If you are using GridClientDeleteColumn better approch is to try from client side. For that attach OnRowDeleting client event and try the following.

Javascript:
function OnRowDeleting(sender, args)
  {
        if (args.get_gridDataItem().get_cell("ColumnUniqueName").innerText == "1")//checking for the cell text.
         {
            args.set_cancel(true);
            args.get_gridDataItem().set_visible(false);
        }
  }

If you want to try from server side. Here is the sample code.
C#:
protected void RadGrid1_DeleteCommand(object sender, Telerik.Web.UI.GridCommandEventArgs e)
 {
      if (e.Item is GridDataItem)
       {
           GridDataItem item = (GridDataItem)e.Item;
           if (item["ColumnUniqueName"].Text == "1")/checks for the text
           {
               e.Canceled = true;
               e.Item.Visible = false;//hiding the row
           }
       }
  }

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