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

[Solved] Move single item between cells

3 Answers 94 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Johannes Arevärn
Top achievements
Rank 1
Johannes Arevärn asked on 25 Sep 2009, 08:44 AM
Hi!

I have a RadGrid on my page with two kinds of columns:
- One GridTemplateColumn that holds information about the items such as name and id.
- Numerous of GridButtonColumns, one column for each week for one year a head. These columns is created in the code-behind.
For each item in the grid i display an image in the correct column if a certified statement returns true.

Now for my question: Is it possible to move these images to another cell but in the same row (for the same item). If its possible i would like som kind of event to be triggered so I will be able to perform updates to the database.

Regards,
Johannes

3 Answers, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 30 Sep 2009, 10:40 AM
Hi Johannes,

Try the following code snippet in order to display image on corresponding column according to the requirement.

ASPX:
 
<telerik:GridButtonColumn UniqueName="ButtonColumn1" ImageUrl="../Images/image1.gif"  ButtonType="ImageButton" CommandName="Command1"
</telerik:GridButtonColumn> 
 <telerik:GridButtonColumn UniqueName="ButtonColumn2" ImageUrl="../Images/image2.gif" ButtonType="ImageButton" CommandName="Command2"
</telerik:GridButtonColumn> 

C#:
 
protected void RadGrid1_ItemDataBound(object sender, Telerik.Web.UI.GridItemEventArgs e) 
    if (e.Item is GridDataItem) 
    { 
        GridDataItem item = (GridDataItem)e.Item; 
        if (condition) // Here check for condition 
        { 
            (item["ButtonColumn1"].Controls[0] as ImageButton).Visible = false// Hide the default image 
            (item["ButtonColumn2"].Controls[0] as ImageButton).ImageUrl = "../Images/image1.gif"// Set the image url to new cell 
        } 
    } 
I am not quite sure about the update part. The UpdateCommand can be invoked by using fireCommand function.
Could you provide some more information about the scenario, if this does not help?

-Shinu.
0
Johannes Arevärn
Top achievements
Rank 1
answered on 30 Sep 2009, 10:52 AM
Hello!

Thank you, I will try the enclosed code. But I'm not sure how to perform the drag and drop? There is a feature in the RadGrid that allow rows to be moved up and down. If that is possible to do with one single tablecell but instead move left-right, that would be awesome for my application.

Regards, Johannes 

0
Johannes Arevärn
Top achievements
Rank 1
answered on 22 Dec 2009, 01:15 PM
Hello Shinu!

I will try to explain the functionality:

A RadGrid on the page containing:
 - one column with description such as "Building nr 1" 
 - multiple columns that represents a date
 

                    20091221    20091228    20100104    20100111                            
Building nr 1        x                    
Building nr 2        x                  x  
Building nr 3                                               x        

The x-symbols represents that some kind of work needs to be done that certain column specified date.
The problem for me is that I want to drag and drop these x:es to another column but in the same row.
It should be possible to move an img-object to a new table cell inside the tablerow parent.

I would really appreciate some help in this matter though I am out of ideas.

Regards, Johannes

Tags
Grid
Asked by
Johannes Arevärn
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
Johannes Arevärn
Top achievements
Rank 1
Share this question
or