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

Separate Insert/Cancel Buttons in Insert Mode

3 Answers 154 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Landon
Top achievements
Rank 2
Landon asked on 19 Apr 2011, 10:33 PM
Hi

I'm currently developing Tablet based Web Application using Telerik Controls.  I'm trying to prevent users from clicking/touching the cancel button when trying Inserting an item into the Grid. Is there a way to move the Cancel Image Button to the right hand side of the items when in Insert Mode?

I'm assuming I could build custom Cancel/Insert Buttons using RadButtonColumns on either side, but was hoping that there's maybe a simpler/cleaner way of achieving this.

Best Regards,

Landon

3 Answers, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 20 Apr 2011, 07:30 AM
Hello,

You can change the styling of CancelButton using CSS. Give a try with the following code in the ItemCreatedEvent.

C#:
protected void RadGrid1_ItemCreated(object sender, GridItemEventArgs e)
   {
       if((e.Item is GridEditableItem && e.Item.IsInEditMode)&& (e.Item.OwnerTableView.IsItemInserted))
       {
           LinkButton cancel = (LinkButton)e.Item.FindControl("CancelButton");
           cancel.CssClass = "ChangePosition";
           cancel.Style["color"]="blue";
         }
   }

CSS:
<style type="text/css">
    .ChangePosition
        {
           float:left;
           margin-left:900px;
        }
</style>

Regards,
-Shinu
0
Landon
Top achievements
Rank 2
answered on 20 Apr 2011, 05:16 PM
Shinu,

Unfortunately in my situation this doesn't work, as my Grid is using "InPlace" Edit mode. I apologize for not making myself more clear. Your code does exactly what it says, but since my Insert/Cancel buttons are located within the "GridEditCommandColumn", it is limiting me to only the space provided.

I believe I could take the other route by creating GridTemplateColumns on either side of the Grid, with Imagebuttons set in the "InsertItemTemplate" that will call the Insert/Cancel functions accordingly. Is this the only route I can take with this?

I currently am using the following code which disables the EditCommandColumn from showing unless in Insert Mode:

protected void LabourGrid_ItemCreated(object sender, GridItemEventArgs e)
        {
            if (e.Item is GridHeaderItem)
                LabourGrid.MasterTableView.GetColumn("Edit").Display = LabourGrid.MasterTableView.IsItemInserted;
            if (e.Item is GridEditableItem && !e.Item.IsInEditMode)
                (e.Item as GridEditableItem)["Edit"].Controls[0].Visible = false;
        }

I have also attached an image of the Grid I am working with.

Best Regards,

Landon
0
Mira
Telerik team
answered on 26 Apr 2011, 09:50 AM
Hello Landon,

Please try using the following code and let me know whether it helps:
protected void RadGrid1_ItemCreated(object sender, GridItemEventArgs e)
   {
       if((e.Item is GridEditableItem && e.Item.IsInEditMode)&& (e.Item.OwnerTableView.IsItemInserted))
       {
           LinkButton cancel = (LinkButton)e.Item.FindControl("CancelButton");
           cancel.Enabled = false;
         }
   }

Kind regards,
Mira
the Telerik team

Browse the vast support resources we have to jump start your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.

Tags
Grid
Asked by
Landon
Top achievements
Rank 2
Answers by
Shinu
Top achievements
Rank 2
Landon
Top achievements
Rank 2
Mira
Telerik team
Share this question
or