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

[Solved] How to show delete for selective rows?

2 Answers 129 Views
Grid
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Kapil Koli
Top achievements
Rank 1
Kapil Koli asked on 10 Mar 2010, 10:31 AM

Hi,
    I am trying to server editing for grid.
    I need to show Delete links for selective rows in my grid.
    But the grid is showing delete links for all rows. What may be the reason behind this?
    Following is my code.
<%int index = 0; %>

  <%Html.Telerik().Grid(Model)

    .Name("Grid")

    .Toolbar(commands => commands.Insert())

    .DataKeys(keys => keys.Add(c => c.RoleID))

    .DataBinding(dataBinding => dataBinding

      .Server()

        .Select("SelectRole", "Home")

        .Insert("InsertRole", "Home")

        .Update("SaveRole", "Home")

        .Delete("DeleteRole", "Home")

    )

    .Columns(

    columns =>

      {

        columns.Add(o =>

          {

            %>

              <%= Html.Encode(o.Description)%>

            <%

          })

          .Title("Description");

 

        columns.Add(o =>

          { 

            %>

            <%if (o.IsStatusEnabled)

              {%>

                  <%=Html.Encode("Enabled") %>

              <%}

              else

              {%>

                   

                    <%=Html.Encode("Disabled")%>

              <%}

               %>

             

            <%

          })

          .Title("Status")

          .Width("8%");

        columns.Command(commands =>

        {

 

          commands.Edit();

          if (Model. Info.ElementAt(index).IsDefaultRole == false)

          {

            commands.Delete();

          }

          index++;

        })

        })

        .Render();       

  %>

Thanks,
Kapil

2 Answers, 1 is accepted

Sort by
0
Georgi Krustev
Telerik team
answered on 10 Mar 2010, 11:01 AM
Hello Kapil Koli,

The used approach will not help you to achieve the required functionality. The Columns(...) method is used to define columns and it is called once, not for every row.

Unfortunately there is no server event which will allow to define the content of the rows while they are
configured.

If you can use JavaScript, you can try to hide the delete buttons on the client.

Regards,
Georgi Krustev
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
Kapil Koli
Top achievements
Rank 1
answered on 11 Mar 2010, 06:36 AM
Thanks Georgi.
Can you please explain/guide me about how to do this through script?
Can I get control over grid commands - Edit & Delete? It would be very useful then.
One more query -
What can I do to show image links instead of "Delete' in grid?
I think from you reply that this again can be done using scripts.

Thanks,
Kapil
Tags
Grid
Asked by
Kapil Koli
Top achievements
Rank 1
Answers by
Georgi Krustev
Telerik team
Kapil Koli
Top achievements
Rank 1
Share this question
or