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

[Solved] displeased

7 Answers 198 Views
GridView
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Scott Nolen
Top achievements
Rank 1
Scott Nolen asked on 20 Sep 2010, 10:20 PM
very displeased with the upgrade to silverlight 4 telerik controls and the support received for the problems we are having,

704-473-7139

7 Answers, 1 is accepted

Sort by
0
Hristo
Telerik team
answered on 23 Sep 2010, 09:58 AM
Hello Scott Nolen,

I am sorry to hear about your frustration while using our controls.

Could you provide more details about your upgrading issues? I went through your support threads and all of them seem to be addressed by our support staff.

Regards,
Hristo
Unit Manager
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
Scott Nolen
Top achievements
Rank 1
answered on 24 Sep 2010, 04:10 PM
One of my issues has thankfully been resolved. thank you for that.

I have another now that is related to the upgrade from version 3 to 4. We have a custom routine that implements word wrapping in a silverlight 4 GridViewDataColumn/celleditemplate TextBox. It was working perfectly in version 3 of the telerik silverlight controls. One obvious problem to us is that the below code is not clearing the selectedtext or setting the selectedlength when the cell goes into edit mode. It basically sets the selected text to all of the characters in the textbox, when you type a character it overlays everything in the textbox because all were selected and then reselects that single character. At this point the textbox contains only a single character that is always selected as you type.

Attachments:
selected1 : Intial look with focus on Pkg Type.
selected2 : User has clicked the Description cell and BALE is auto selected. (DO NOT WANT THIS BEHAVIOR)
selected3 : User has keyed letter A.
selected4 : User has keyed letter B.
selected5 : User has keyed letter C.

(What you should be seeing at this point is ABC and it should not be selected and the cursor should be just after the C character. This was functioning this way with the silverlight 3 controls)


 

 

 

 

 

 

<telerikGridView:GridViewDataColumn Header="Description" DataMemberBinding="{Binding Description, Mode=TwoWay}" Width="225" >

 

 

 

 

    <telerikGridView:GridViewDataColumn.CellTemplate>

 

 

 

 

        <DataTemplate>

 

 

 

 

            <TextBlock TextWrapping="NoWrap" Text="{Binding Description}" />

 

 

 

 

        </DataTemplate>

 

 

 

 

    </telerikGridView:GridViewDataColumn.CellTemplate>

 

 

 

 

    <telerikGridView:GridViewDataColumn.CellEditTemplate>

 

 

 

 

        <DataTemplate>

 

 

 

 

            <TextBox x:Name="tbDescEdit"     
                Loaded
="TextBox_Loaded"     
                TextChanged
="tbBillBodyDesc_TextChanged"         
                TextWrapping="NoWrap" 
                Text
="{Binding Description, Mode=TwoWay}" >
            </
TextBox>

 

 

 

 

        </DataTemplate>

 

 

 

 

    </telerikGridView:GridViewDataColumn.CellEditTemplate>

 

 

 

 

</telerikGridView:GridViewDataColumn>

 

 

 

 


 

private void TextBox_Loaded(object sender, RoutedEventArgs e)

 

{

 

 

    TextBox lTB = (sender as TextBox);

 

 

 

    int lCurRow = gvBillBody.Items.IndexOf(gvBillBody.CurrentItem);

 

 

 

    int lSelRow = gvBillBody.Items.IndexOf(gvBillBody.SelectedItem);

 

 

 

    if (_NewBillBodyPOS != null && lSelRow == _NewBillBodyPOS.RowNumber)

 

    {

 

 

        if (gvBillBody.SelectedItem != gvBillBody.CurrentItem)

 

        {

            gvBillBody.CommitEdit();

            gvBillBody.SelectedItems.Clear();

            gvBillBody.SelectedItems.Add(BillBodyData[_NewBillBodyPOS.RowNumber]);

            gvBillBody.CurrentItem = BillBodyData[_NewBillBodyPOS.RowNumber];

            gvBillBody.BeginEdit();

            ((

 

GridViewCellgvBillBody.CurrentCell.ParentRow.Cells[_NewBillBodyPOS.ColumnNumber]).IsCurrent
             =
true;

 

            gvBillBody.BeginEdit();

        }

        lTB.Focus();

        lTB.SelectionStart = _NewBillBodyPOS.CellCursorPosition;

    }

    lTB.SelectionLength = 0;

 

}

 

 

 

private void tbBillBodyDesc_TextChanged(object sender, TextChangedEventArgs e)

 

{

 

 

 

    GridPosition lTmpPOS;

 

 

 

    GridPosition lCurPOS = new GridPosition();

 

 

 

    int loc_col = 4;

 

 

 

    int loc_max = 30;

 

 

 

    WordWrap lWW = new WordWrap();

 

 

 

    TextBox lTB = (TextBox)sender;

 

    lCurPOS.RowNumber = gvBillBody.Items.IndexOf(gvBillBody.CurrentItem);

    lCurPOS.ColumnNumber = loc_col;

    lCurPOS.CellCursorPosition = lTB.SelectionStart;

 

 

    if (lCurPOS.CellCursorPosition > 0)

 

    {

        lTmpPOS = lWW.WrapBillBodyCol(

 

ref BillBodyData, ref gvBillBody, ref lTB, loc_col, loc_max);

 

 

 

        if (lTmpPOS != null)

 

        {

 

 

            string LogText = "";

 

            LogText +=

 

"WW: row=" + lTmpPOS.RowNumber.ToString();

 

            LogText +=

 

"; col=" + lTmpPOS.ColumnNumber.ToString();

 

            LogText +=

 

"; celPOS=" + lTmpPOS.CellCursorPosition.ToString();

 

            LogText +=

 

"\r\n";

 

            _NewBillBodyPOS = lTmpPOS;

            gvBillBody.CommitEdit();

            gvBillBody.SelectedItems.Clear();

            gvBillBody.SelectedItems.Add(gvBillBody.Items[lTmpPOS.RowNumber]);

            gvBillBody.SelectedItem = gvBillBody.SelectedItems[0];

            gvBillBody.CurrentItem = BillBodyData[lTmpPOS.RowNumber];

            gvBillBody.BeginEdit();

            ((

 

GridViewCell)gvBillBody.CurrentCell.ParentRow.Cells[lTmpPOS.ColumnNumber]).IsCurrent
             =
true;

 

            gvBillBody.BeginEdit();

        }

    }

}

 

 

0
Nedyalko Nikolov
Telerik team
answered on 30 Sep 2010, 10:14 AM
Hello Scott Nolen,

Sorry for the late answer.

Indeed the default behavior when cell enters into edit mode and editing element contains TextBox is to select all text inside this textbox. Unfortunately with the current version of RadGridView you cannot override this behavior. We reconsidered this prepare cell for edit action and finally we will introduce a coupe of events (PreparingCellForEdit and PreparedCellForEdit) which will help with such tasks. As usual -ing event will be raised just before RadGridView's default "prepare cell for edit action" and -ed event will be raised just after.

You should avoid TextBox.Loaded event since RadGridView could change something during "Preparing cell for edit" operation.

I'm attaching an example that demonstrates this approach. The example is built with a private build assemblies which generally is a preview of the next latest internal build (which will be uploaded tomorrow).

P.S. By the way I do not understand why do you call RadGridView.BeginEdit() method twice in textbox_change and textbox_loaded handlers.

Kind regards,
Nedyalko Nikolov
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
Scott Nolen
Top achievements
Rank 1
answered on 05 Oct 2010, 05:00 PM
This is exactly what we needed. Thank you for your help. I am very pleased.
0
Scott Nolen
Top achievements
Rank 1
answered on 09 Nov 2010, 12:12 AM
We are still having trouble with our word wrap routine. It is causing a latency that did not exist before the upgrade when the user types on the keyboard. It actually skips characters as they are typed. we are using the new preparedcellforedit routine.


Xaml for the Grid(Key event : PreparedCellForEdit) :

 

        <telerikGridView:RadGridView x:Name="gvBillBody" Grid.Column="0" Grid.Row="0" VerticalAlignment="Top" HorizontalAlignment="Left" Margin="5" Height="150"

                                     IsFilteringAllowed="False"

                                     ShowGroupPanel="False"

                                     CanUserFreezeColumns="False"

                                     CanUserReorderColumns="False"

                                     CanUserSortColumns="False"

                                     CanUserInsertRows="False"

                                     CanUserDeleteRows="True"

                                     AutoGenerateColumns="False"

                                     RowEditEnded="gvBillBody_RowEditEnded"

                                     GotFocus="gvBillBody_GotFocus"

                                     CanUserResizeColumns="False"

                                     BeginningEdit="gvBillBody_BeginningEdit"

                                     CellEditEnded="gvBillBody_CellEditEnded"

                                     ShowColumnFooters="True"

                                     CellValidating="gvBillBody_CellValidating"

                                     CellValidated="gvBillBody_CellValidated"

                                     PreparedCellForEdit="gvBillBody_PreparedCellForEdit"

                                     IsSynchronizedWithCurrentItem="True"

                                     >

           

 

 

Column we are attempting to wrap the text with :

                <telerikGridView:GridViewDataColumn Header="Description" DataMemberBinding="{Binding Description, Mode=TwoWay}" Width="225" >

                    <telerikGridView:GridViewDataColumn.CellTemplate>

                        <DataTemplate>

                            <TextBlock TextWrapping="NoWrap" Text="{Binding Description}" />

                        </DataTemplate>

                    </telerikGridView:GridViewDataColumn.CellTemplate>

                    <telerikGridView:GridViewDataColumn.CellEditTemplate>

                        <DataTemplate>

                            <TextBox x:Name="tbDescEdit" Loaded="TextBox_Loaded" TextChanged="tbBillBodyDesc_TextChanged" KeyDown="tbDescEdit_KeyDown" TextWrapping="NoWrap" Text="{Binding Description, Mode=TwoWay}" ></TextBox>

                        </DataTemplate>

                    </telerikGridView:GridViewDataColumn.CellEditTemplate>

                </telerikGridView:GridViewDataColumn>

 

 

 

Key routines :

 

(Replaced TextBox_Loaded with the new preparedcellforedit routine after upgrade from 3 to 4)

 

        private void TextBox_Loaded(object sender, RoutedEventArgs e)

        {

            //TextBox lTB = (sender as TextBox);

            //int lCurRow = gvBillBody.Items.IndexOf(gvBillBody.CurrentItem);

            //int lSelRow = gvBillBody.Items.IndexOf(gvBillBody.SelectedItem);

            //if (_NewBillBodyPOS != null && lSelRow == _NewBillBodyPOS.RowNumber)

            //{

            //    string LogText = "";

            //    LogText += "TBL: row=" + _NewBillBodyPOS.RowNumber.ToString();

            //    LogText += "; col=" + _NewBillBodyPOS.ColumnNumber.ToString();

            //    LogText += "; celPOS=" + _NewBillBodyPOS.CellCursorPosition.ToString();

            //    LogText += "\r\n";

            //    //tbWrapInf.Text += LogText;

            //    if (gvBillBody.SelectedItem != gvBillBody.CurrentItem)

            //    {

            //        gvBillBody.CommitEdit();

            //        gvBillBody.SelectedItems.Clear();

            //        ////gvBillBody.ItemsSource = BillBodyData;

            //        ////gvBillBody.Rebind();

            //        gvBillBody.SelectedItems.Add(BillBodyData[_NewBillBodyPOS.RowNumber]);

            //        gvBillBody.CurrentItem = BillBodyData[_NewBillBodyPOS.RowNumber];

            //        gvBillBody.BeginEdit();

            //        ((GridViewCell)gvBillBody.CurrentCell.ParentRow.Cells[_NewBillBodyPOS.ColumnNumber]).IsCurrent = true;

            //        gvBillBody.BeginEdit();

 

            //    }

            //    lTB.Focus();

            //    lTB.SelectionStart = _NewBillBodyPOS.CellCursorPosition;

            //}

            //lTB.SelectionLength = 0;

           

        }

 

 

(this one is being used)

        private void tbDescEdit_KeyDown(object sender, KeyEventArgs e)

        {

            TextBox lTB = (sender as TextBox);

            int lMaxLength = 30;

            int lCurROW = 0;

            WordWrap lWW = new WordWrap();

 

            switch (e.Key)

            {

                case Key.Enter:

                    int lCursorPOS = 0;

                    string lBreakString = "";

                    lCursorPOS = lTB.SelectionStart;

                    if (lCursorPOS < lTB.Text.Trim().Length)

                    {

                        lBreakString = lTB.Text.Substring(lCursorPOS);

                        lTB.Text = lTB.Text.Substring(0, lCursorPOS);

                    }

                    lTB.Text += "\r";

                    lCurROW = gvBillBody.Items.IndexOf(gvBillBody.CurrentItem);

                    gvBillBody.CommitEdit();

                    if (gvBillBody.CurrentCell.IsInEditMode == true)

                        return;

                    int lNewIndex = lCurROW + 1;

                    BillBodyData.Insert(lNewIndex, new CarotrackWeb.BillBody.BookingWCFsvc.BillBody());

                    if (lBreakString.LastIndexOf(" ") == lBreakString.Length - 1 && lBreakString.Length > 0)

                        BillBodyData[lNewIndex].Description = lBreakString.Trim() + " ";

                    else

                        BillBodyData[lNewIndex].Description = lBreakString.Trim();

                    _NewBillBodyPOS = new GridPosition();

                    _NewBillBodyPOS.RowNumber = lNewIndex;

                    _NewBillBodyPOS.ColumnNumber = 4;

                    _NewBillBodyPOS.CellCursorPosition = 0;

                    GridPosition lTmpPOS1 = lWW.WrapBillBodyCol(ref BillBodyData, ref gvBillBody, ref lTB, 4, lMaxLength);

                    gvBillBody.SelectedItems.Clear();

                    gvBillBody.SelectedItems.Add(gvBillBody.Items[_NewBillBodyPOS.RowNumber]);

                    gvBillBody.SelectedItem = gvBillBody.SelectedItems[0];

                    gvBillBody.CurrentItem = BillBodyData[_NewBillBodyPOS.RowNumber];

                    gvBillBody.BeginEdit();

                    ((GridViewCell)gvBillBody.CurrentCell.ParentRow.Cells[_NewBillBodyPOS.ColumnNumber]).IsCurrent = true;

                    gvBillBody.BeginEdit();

                    //lCurROW = gvBillBody.Items.IndexOf(gvBillBody.CurrentItem);

                    //gvBillBody.CommitEdit();

                    //if (gvBillBody.CurrentCell.IsInEditMode == true)

                    //    return;

                    //_NewBillBodyPOS.RowNumber = lCurROW - 1;

                    //_NewBillBodyPOS.ColumnNumber = 4;

                    //_NewBillBodyPOS.CellCursorPosition = BillBodyData[_NewBillBodyPOS.RowNumber].Description.Length;

                    //gvBillBody.SelectedItems.Clear();

                    //gvBillBody.SelectedItems.Add(gvBillBody.Items[_NewBillBodyPOS.RowNumber]);

                    //gvBillBody.SelectedItem = gvBillBody.SelectedItems[0];

                    //gvBillBody.CurrentItem = BillBodyData[_NewBillBodyPOS.RowNumber];

                    //gvBillBody.BeginEdit();

                    //((GridViewCell)gvBillBody.CurrentCell.ParentRow.Cells[_NewBillBodyPOS.ColumnNumber]).IsCurrent = true;

                    //gvBillBody.BeginEdit();

                    break;

                case Key.Back:

                    //if backspace then check to see if there is another

                    //row above that is part of the same section and

                    //put the cursor in that row at the end of the text

 

                   

                    lCurROW = gvBillBody.Items.IndexOf(gvBillBody.CurrentItem);

                    CarotrackWeb.BillBody.BookingWCFsvc.BillBody lBB = gvBillBody.CurrentItem as CarotrackWeb.BillBody.BookingWCFsvc.BillBody;

                    List<string> lColsToOmitFromDataCheck = new List<string>();

                    lColsToOmitFromDataCheck.Add("Description");

                    lColsToOmitFromDataCheck.Add("Marks");

                    lColsToOmitFromDataCheck.Add("HardReturn");

                    if (lTB.SelectionStart == 0 && lCurROW > 0 && lWW.RowHasOtherData<CarotrackWeb.BillBody.BookingWCFsvc.BillBody>(lBB, lColsToOmitFromDataCheck) == false)

                    {

                        gvBillBody.CommitEdit();

                        if (gvBillBody.CurrentCell.IsInEditMode == true)

                            return;

                        _NewBillBodyPOS = new GridPosition();

                        _NewBillBodyPOS.RowNumber = lCurROW - 1;

                        _NewBillBodyPOS.ColumnNumber = 4;

                        BillBodyData[_NewBillBodyPOS.RowNumber].Description = BillBodyData[_NewBillBodyPOS.RowNumber].Description.Trim();

                        BillBodyData[_NewBillBodyPOS.RowNumber].HardReturn = false;

                        _NewBillBodyPOS.CellCursorPosition = BillBodyData[_NewBillBodyPOS.RowNumber].Description.Length;

                        GridPosition lTmpPOS = lWW.WrapBillBodyCol(ref BillBodyData, ref gvBillBody, ref lTB, 4, lMaxLength);

                        _NewBillBodyPOS = lTmpPOS;

                        gvBillBody.SelectedItems.Clear();

                        gvBillBody.SelectedItems.Add(gvBillBody.Items[_NewBillBodyPOS.RowNumber]);

                        gvBillBody.SelectedItem = gvBillBody.SelectedItems[0];

                        gvBillBody.CurrentItem = BillBodyData[_NewBillBodyPOS.RowNumber];

                        gvBillBody.BeginEdit();

                        ((GridViewCell)gvBillBody.CurrentCell.ParentRow.Cells[_NewBillBodyPOS.ColumnNumber]).IsCurrent = true;

                        gvBillBody.BeginEdit();

                    }

                    break;

                case Key.Delete:

                    lCurROW = gvBillBody.Items.IndexOf(gvBillBody.CurrentItem);

                    if (lTB.SelectionStart == lTB.Text.Length && BillBodyData[lCurROW].HardReturn == true)

                    {

                        _NewBillBodyPOS = new GridPosition();

                        BillBodyData[lCurROW].HardReturn = false;

                        GridPosition lTmpPOSdel = lWW.WrapBillBodyCol(ref BillBodyData, ref gvBillBody, ref lTB, 4, lMaxLength);

                        _NewBillBodyPOS = lTmpPOSdel;

                        gvBillBody.SelectedItems.Clear();

                        gvBillBody.SelectedItems.Add(gvBillBody.Items[_NewBillBodyPOS.RowNumber]);

                        gvBillBody.SelectedItem = gvBillBody.SelectedItems[0];

                        gvBillBody.CurrentItem = BillBodyData[_NewBillBodyPOS.RowNumber];

                        gvBillBody.BeginEdit();

                        ((GridViewCell)gvBillBody.CurrentCell.ParentRow.Cells[_NewBillBodyPOS.ColumnNumber]).IsCurrent = true;

                        gvBillBody.BeginEdit();

                    }

                    break;

                default:

                    break;

            }

 

 

 

(this one is being used)

 

        private void tbBillBodyDesc_TextChanged(object sender, TextChangedEventArgs e)

        {

            GridPosition lTmpPOS;

            GridPosition lCurPOS = new GridPosition();

            int loc_col = 4;

            int loc_max = 30;

            WordWrap lWW = new WordWrap();

            TextBox lTB = (TextBox)sender;

 

            lCurPOS.RowNumber = gvBillBody.Items.IndexOf(gvBillBody.CurrentItem);

            lCurPOS.ColumnNumber = loc_col;

            lCurPOS.CellCursorPosition = lTB.SelectionStart;

 

            if (lCurPOS.CellCursorPosition > 0)

            {

                lTmpPOS = lWW.WrapBillBodyCol(ref BillBodyData, ref gvBillBody, ref lTB, loc_col, loc_max);

 

                if (lTmpPOS != null)

                {

                    string LogText = "";

                    LogText += "WW: row=" + lTmpPOS.RowNumber.ToString();

                    LogText += "; col=" + lTmpPOS.ColumnNumber.ToString();

                    LogText += "; celPOS=" + lTmpPOS.CellCursorPosition.ToString();

                    LogText += "\r\n";

                    _NewBillBodyPOS = lTmpPOS;

                    gvBillBody.CommitEdit();

                    gvBillBody.SelectedItems.Clear();

                    //gvBillBody.SelectedItems.Add(gvBillBody.Items[lTmpPOS.RowNumber]);

                    //gvBillBody.SelectedItem = gvBillBody.SelectedItems[0];

                    gvBillBody.CurrentItem = BillBodyData[lTmpPOS.RowNumber];

                    gvBillBody.BeginEdit();

                    ((GridViewCell)gvBillBody.CurrentCell.ParentRow.Cells[lTmpPOS.ColumnNumber]).IsCurrent = true;

                    gvBillBody.BeginEdit();

                }

 

            }

            //(gvBillBody.Columns[4].CreateCellEditElement(gvBillBody.CurrentCell, (gvBillBody.CurrentItem as BillBody).Description ) as TextBox).Text = gvBillBody.CurrentCell.Value.ToString();

            //(gvBillBody.Columns[4].CreateCellEditElement(gvBillBody.CurrentCell, (gvBillBody.CurrentItem as BillBody).Description ) as TextBox).SelectionLength = 0;

        }

 

 

(MAIN ROUTINE in a class)

 

        public GridPosition WrapBillBodyCol(ref BillBodyRows GridData, ref RadGridView loc_grid, ref TextBox tbEdit, int loc_col, int loc_MaxLEN)

        {

           

            GridPosition lNewPos = new GridPosition();

            try

               {           

                int loc_curPOS;

                int loc_curROW;

                int loc_newPOS = 0;

                int loc_newROW = 0;

                int loc_StartRow = 0;

                int loc_endrow = 0;

                int loc_absPOS = 0;

                int loc_newABS = 0;

                string loc_Text;

                string loc_newText;

                bool loc_Flag; bool loc_LineBreak;

                List<string>lColsToOmitFromDataCheck = new List<string>();

               

                loc_curPOS = tbEdit.SelectionStart;

               

                //loc_curROW = loc_grid

 

                loc_curROW = loc_grid.Items.IndexOf(loc_grid.CurrentItem);

 

                loc_grid.CommitEdit();

                if (loc_grid.CurrentCell.IsInEditMode==true )

                    return null;

                lColsToOmitFromDataCheck.Add((loc_grid.Columns[loc_col] as GridViewDataColumn).DataMemberBinding.Path.Path);

                lColsToOmitFromDataCheck.Add("Marks");

                lColsToOmitFromDataCheck.Add("HardReturn");

                //First find the begining row for this section

                loc_Flag = false;

                for (int i = loc_curROW; i >= 0; i--)

                        {

                    CarotrackWeb.BillBody.BookingWCFsvc.BillBody lTmpData = GridData[i] as CarotrackWeb.BillBody.BookingWCFsvc.BillBody;

                  //loc_grid.Columns[loc_col].

                    if (RowHasOtherData<CarotrackWeb.BillBody.BookingWCFsvc.BillBody>(lTmpData, lColsToOmitFromDataCheck) == true)

                    {

                        loc_StartRow = i;

                        loc_Flag = true;

                        break;

                    }                         

                    if (loc_Flag)

                        break;

                        }

               if (!loc_Flag)

                   loc_StartRow=0;

                //next find the ending row for this section

               loc_Flag = false;

                for (int i = loc_curROW + 1; i < loc_grid.Items.Count; i++)

                {

                    CarotrackWeb.BillBody.BookingWCFsvc.BillBody lTmpData = (CarotrackWeb.BillBody.BookingWCFsvc.BillBody)loc_grid.Items[i];

                  //loc_grid.Columns[loc_col].

                    if (RowHasOtherData<CarotrackWeb.BillBody.BookingWCFsvc.BillBody>(lTmpData, lColsToOmitFromDataCheck) == true)

                    {

                        loc_endrow = i -1;

                        loc_Flag = true;

                        break;

                    }                         

                    if (loc_Flag)

                        break;

                }

   

                if (!loc_Flag)  //if no data found in other cols on any other row the set to total num of rows

                    loc_endrow = loc_grid.Items.Count -1;

                if (loc_endrow < loc_StartRow)

                    loc_endrow = loc_StartRow;

                //Build full string

                loc_Text = "";

                for (int i = loc_StartRow; i <= loc_endrow; i++)

                   {

                      if (i == loc_curROW)

                  {

                     loc_absPOS = loc_Text.Length + loc_curPOS;

                     loc_Text = loc_Text + (GridData[i] as CarotrackWeb.BillBody.BookingWCFsvc.BillBody).Description;

                  }

                    else

                      loc_Text = loc_Text + (GridData[i] as CarotrackWeb.BillBody.BookingWCFsvc.BillBody).Description;

                  if ((GridData[i] as CarotrackWeb.BillBody.BookingWCFsvc.BillBody).HardReturn)

                  {

                      loc_Text += "\r";

                  }

                   }

            

                //************************************************************      

                int loc_x = loc_StartRow;

                int loc_s;

                int loc_h;

                int loc_z;

                    loc_Flag = false;

                    loc_Text = loc_Text.ToUpper();

                        do

                        {

                            loc_h = 0;

                            loc_s = 0;

                            loc_LineBreak = false;

 

                            if (loc_Text.Length > loc_MaxLEN)

                            {

                                loc_s = loc_Text.LastIndexOf(" ",loc_MaxLEN) +1;

                                loc_h = loc_Text.LastIndexOf("-", loc_MaxLEN) +1;

                                if (loc_s == 0)  //if no spaces then set to MAX length

                                    loc_s = loc_MaxLEN;

                                else if (loc_s > loc_MaxLEN)

                                    loc_s = loc_MaxLEN;

                                //else if (loc_s > 0 && loc_s < gbl_CutOff)

                                //    loc_s = gbl_CutOff;

                                loc_z = loc_Text.IndexOf("\r",0,loc_MaxLEN + 1);

                            }

                            else

                            {

                                loc_s = loc_Text.Length;

                                loc_z = loc_Text.IndexOf("\r");

                            }

                            if (loc_z > 0 && loc_z < loc_MaxLEN ) { //if a return exists then break there

                                loc_newText = loc_Text.Substring(0,loc_z + 1); //TODO verify

                                loc_Text = loc_Text.Substring(loc_z + 1,loc_Text.Length - loc_newText.Length).ToUpper();

                                //loc_newText = loc_newText.Replace("\r", "");

                                loc_LineBreak = true;

                            }

                            else if (loc_h > loc_s)

                            {

                                loc_newText = loc_Text.Substring(0,loc_h).ToUpper();

                                loc_Text = loc_Text.Substring(loc_h, loc_Text.Length - loc_newText.Length).ToUpper();

                            }

                            else

                            {

                                loc_newText = loc_Text.Substring(0, loc_s).ToUpper();

                                loc_Text = loc_Text.Substring(loc_newText.Length, loc_Text.Length - loc_newText.Length).ToUpper();

                            }

 

                            //If the new absoulute POSition has not been determined then

                            if (loc_newABS + loc_newText.Length >= loc_absPOS && !loc_Flag)

                            {

                               loc_newPOS = loc_absPOS - loc_newABS;

                                if (loc_newPOS >= 1)

                                {

                                    if (loc_newText.LastIndexOf("\r",loc_newPOS)== loc_newPOS - 1 )

                                    {

                                        loc_newROW = loc_x + 1;

                                        loc_newPOS = 0;

                                    }

                                    else

                                        loc_newROW = loc_x;

                                }

                                else

                                    loc_newROW = loc_x;

                               

                                loc_Flag = true;

                            }

                            else

                                loc_newABS = loc_newABS + loc_newText.Length;

                            //Remove place holder for hard return

                            loc_newText = loc_newText.Replace("\r", "");

 

                            CarotrackWeb.BillBody.BookingWCFsvc.BillBody lBB;

                            if (loc_x > loc_endrow)

                            {

                                //Add new row

                                if (loc_x > GridData.Count - 1)

                                {

                                    lBB = new CarotrackWeb.BillBody.BookingWCFsvc.BillBody();

                                    lBB.Description = loc_newText;

                                    GridData.Add(lBB);

                                }

                                else

                                {

                                    lBB = new CarotrackWeb.BillBody.BookingWCFsvc.BillBody();

                                    lBB.Description = loc_newText.ToUpper();

                                    GridData.Insert(loc_x,lBB);

                                    loc_grid.ItemsSource = GridData;

                                }

                            }

                            else

                            {

                                GridData[loc_x].Description= loc_newText.ToUpper();

                            }

                            if (loc_LineBreak)

                                GridData[loc_x].HardReturn = true;

                            else

                                GridData[loc_x].HardReturn = false;

 

                            loc_x += 1;

                        } while (loc_Text.Length > 0 || loc_LineBreak);

 

                        if (loc_x <= loc_endrow)   //Blank out any remaining rows

                        {

                            for (int p = loc_endrow; p >= loc_x; p--)

                            {

                                GridData[p].Description = "";

                            }

                        }

                        else if (loc_endrow == GridData.Count - 1)

                            GridData.Add(new CarotrackWeb.BillBody.BookingWCFsvc.BillBody());

                        lNewPos.RowNumber = loc_newROW;

                        lNewPos.ColumnNumber = loc_col;

                        lNewPos.CellCursorPosition = loc_newPOS;

 

                        //loc_grid.SelectedItems.Clear();

                        //.SelectedItems.Add(loc_grid.Items[loc_x]);

 

                        loc_z = loc_newText.ToString().IndexOf("\r");

                         if (loc_z > 0 && loc_z == loc_newPOS - 1 && loc_newROW < loc_endrow)

                         {

                             //loc_grid.SelectedItems.Clear();

                             //loc_grid.SelectedItems.Add(loc_grid.Items[loc_x + 1]);

                             lNewPos.RowNumber = loc_newROW + 1;

                         }

               

                         //loc_grid.BeginEdit();

                         //((GridViewCell)loc_grid.CurrentCell.ParentRow.Cells[loc_col]).IsCurrent = true;

                         //loc_grid.BeginEdit();

               

              

                       

                        

//        .ActiveCell.SelStart = loc_newPOS

//        .ActiveCell.SelLength = 0

                //************************************************************

 

                 return lNewPos;

    

               }

               catch (Exception ex)

               {

                     return null;

               }

        }

 

 

0
Nedyalko Nikolov
Telerik team
answered on 11 Nov 2010, 03:55 PM
Hi Scott Nolen,

I think that you could handle RowValidating and do the wrapping there. I'm attaching a sample project that demonstrates this approach. Of course wrapping is a very simple but you could import your custom logic there.
Let me know if this doesn't help.

Best wishes,
Nedyalko Nikolov
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
Scott Nolen
Top achievements
Rank 1
answered on 15 Nov 2010, 05:10 PM
The sample you gave demonstrates wrapping a single column but it does not give the user the view until they move off of the cell to fire row validating. The solution we had in your version 3 control would actually position the cursor to the proper row and also position the cursor whitin the cell with each keystroke. They would not have to leave a cell/row at any time to see how the data was distributed on the rows.  If this is the only way that we can accomplish this with version 4 then we will present it to them and see if they approve. Our customer has to key enter a lot of data and sometimes it has to match another document EXACTLY.

Another thing about the sample, once i key in 90 characters, this creates 3 rows when you first enter the data. Our need requires that if you go back and edit any of these 3 rows then all of the 90 characters for the 3 rows should appear for the user to edit. Once they move off after editing these 90 characters then this data should be redistributed to these 3 rows. It could add rows to the end, change rows in the middle, or delete rows.
Tags
GridView
Asked by
Scott Nolen
Top achievements
Rank 1
Answers by
Hristo
Telerik team
Scott Nolen
Top achievements
Rank 1
Nedyalko Nikolov
Telerik team
Share this question
or