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

How to keep display value and hide of a cell value in WingridView control

1 Answer 78 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Purushottam
Top achievements
Rank 1
Purushottam asked on 02 Mar 2009, 02:18 PM
Hi,
I have a value fetching from database like;

Purushottam Kumar(12478,OC)

 
where I want to show only Purushottam Kumar as display value in the single cell of WinRadGidView and the complete values Purushottam Kumar(12478,OC) or rest of values (12478,OC) should be also available in hidden form in the same cell.

Please help me how I can maintain  the both display value and hidden value in the same cell simulteneously.

Regards,
Purushottam Kumar

1 Answer, 1 is accepted

Sort by
0
Nick
Telerik team
answered on 03 Mar 2009, 06:10 PM
Hi Purushottam,

We are not sure that the grid control should split your data in such way. Anyway, this is the work-around I can think of, however we will suggest rethinking the logic of your application:

private void Form1_Load(object sender, EventArgs e) 
        { 
            DataTable t = new DataTable(); 
            t.Columns.Add("A"); 
            t.Rows.Add("Purushottam Kumar(12478,OC)"); 
            t.Rows.Add("Purushottam Kumar(12478,OC)"); 
 
            this.radGridView1.DataSource = t; 
 
             
        } 
 
        private void radGridView1_CellFormatting(object sender, Telerik.WinControls.UI.CellFormattingEventArgs e) 
        { 
            if (e.CellElement.ColumnInfo.HeaderText == "A"
            { 
                e.CellElement.Text = e.CellElement.RowInfo.Cells["A"].Value.ToString().Substring(0, 17); 
            } 
        } 

Please note that you can use more complicated code in CellFormatting event handler to find the substring you need.

If the column is read-only the above should work properly, however if you need to edit your cells you need to implement further workarounds. You may try to subscribe to CellBeginEdit and CellEndEdit events:

string realValue; 
        private void radGridView1_CellBeginEdit(object sender, Telerik.WinControls.UI.GridViewCellCancelEventArgs e) 
        { 
            realValue = this.radGridView1.ActiveEditor.Value.ToString(); 
            //change value so that the end of the string is not shown
        } 
 
        private void radGridView1_CellEndEdit(object sender, Telerik.WinControls.UI.GridViewCellEventArgs e) 
        { 
            //append the end of your string  
        } 


All the best,
Nick
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
Tags
GridView
Asked by
Purushottam
Top achievements
Rank 1
Answers by
Nick
Telerik team
Share this question
or