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

GridNumericColumnEditor with AllowMultiRowEdit="true"

3 Answers 196 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Scott
Top achievements
Rank 1
Scott asked on 27 Jun 2008, 08:31 PM
I'm customizing the automatic grid editors as follows:

<telerik:RadGrid ID="InvoiceLines" runat="server" AllowMultiRowSelection="true" AllowMultiRowEdit="true" 
    Skin="Office2007" OnNeedDataSource="InvoiceLines_NeedDataSource" AutoGenerateColumns="false" 
    OnUpdateCommand="InvoiceLines_UpdateCommand" OnDeleteCommand="InvoiceLines_DeleteCommand" OnInsertCommand="InvoiceLines_InsertCommand">  
    <ClientSettings> 
        <Selecting AllowRowSelect="true" /> 
    </ClientSettings> 
    <MasterTableView DataKeyNames="Id" ClientDataKeyNames="Id" EditMode="InPlace" AutoGenerateColumns="false" CommandItemDisplay="Bottom" InsertItemDisplay="Bottom">  
        <CommandItemSettings AddNewRecordImageUrl="~/Images/favorites_16.png" AddNewRecordText="Add New Line" RefreshImageUrl="~/Images/document_refresh_16.png" RefreshText="Refresh Lines" /> 
        <Columns> 
            <telerik:GridEditCommandColumn ButtonType="ImageButton" ItemStyle-Width="20px" /> 
            <telerik:GridClientDeleteColumn ButtonType="ImageButton" ItemStyle-Width="20px" ImageUrl="~/Images/trash_16.png" DataType="System.Guid" ConfirmText="Delete this item?" /> 
            <telerik:GridBoundColumn DataField="LineNumber" HeaderText="" ReadOnly="true" ItemStyle-Width="20px" /> 
            <telerik:GridBoundColumn DataField="Description" HeaderText="Description" UniqueName="Description" ColumnEditorID="DescriptionEditor" /> 
            <telerik:GridNumericColumn DataField="Quantity" HeaderText="Qty" UniqueName="Quantity" ItemStyle-Width="50px" ColumnEditorID="QuantityEditor" /> 
            <telerik:GridNumericColumn DataField="PricePerUnit" HeaderText="Price / Rate" UniqueName="PricePerUnit" ItemStyle-Width="50px" ColumnEditorID="PricePerUnitEditor" /> 
            <telerik:GridNumericColumn DataField="TotalPrice" HeaderText="Amount" UniqueName="TotalPrice" ReadOnly="true" ItemStyle-Width="75px" /> 
            <telerik:GridCheckBoxColumn DataField="Taxable" HeaderText="Tax" UniqueName="Taxable" ItemStyle-Width="25px" /> 
        </Columns> 
    </MasterTableView> 
</telerik:RadGrid> 
<telerik:GridTextBoxColumnEditor ID="DescriptionEditor" runat="server">  
    <TextBoxStyle Width="200px" BackColor="Aqua" /> 
</telerik:GridTextBoxColumnEditor> 
<telerik:GridNumericColumnEditor ID="QuantityEditor" runat="server">  
    <NumericTextBox runat="server" Width="50px" /> 
</telerik:GridNumericColumnEditor> 
<telerik:GridNumericColumnEditor ID="PricePerUnitEditor" runat="server">  
    <NumericTextBox runat="server" Width="50px" BackColor="AliceBlue" /> 
</telerik:GridNumericColumnEditor> 

I'm really just trying to adjust the width (it would be nice if the edit controls automatically set their width to the column width), but I added some background colors just to be sure I'm not crazy.

The GridTextBoxColumnEditor always works, but the GridNumericColumnEditor only works if there is only one row in edit mode. Once I put a second row into edit mode the text boxes get huge again and the background color goes away.

Is there an easy fix for this?

3 Answers, 1 is accepted

Sort by
0
Veli
Telerik team
answered on 30 Jun 2008, 01:26 PM
Hello Scott,

Could you please try setting the same formatting options for the column editors in the code behind to see if styles are applied to all or only one edited item. You could do this in the ItemDataBound event handler in the following way:

    void RadGrid1_ItemDataBound(object sender, GridItemEventArgs e) 
    { 
        if (e.Item is GridEditableItem && e.Item.IsInEditMode) 
        { 
            GridEditableItem item = (GridEditableItem)e.Item; 
            (item.EditManager.GetColumnEditor("Description"as GridTextBoxColumnEditor).TextBoxStyle.BackColor = System.Drawing.Color.Aqua; 
            (item.EditManager.GetColumnEditor("Quantity"as GridNumericColumnEditor).NumericTextBox.Width = Unit.Pixel(50); 
            (item.EditManager.GetColumnEditor("PricePerUnit"as GridNumericColumnEditor).NumericTextBox.BackColor = System.Drawing.Color.AliceBlue; 
        } 
    } 

Best wishes,
Veli
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
0
Scott R
Top achievements
Rank 1
answered on 01 Jul 2008, 05:31 AM

Well, that makes the edit boxes look right when multiple rows are in edit mode. However, I've now encountered a new problem (it's probably been there all along, but I just discovered it).

With the grid declaration above when I put two or more rows into edit mode then try to update or cancel one of the rows, I get a server side exception:

"Text property cannot be set. Input string was not in a correct format."} System.Exception {System.InvalidCastException}

Here is the stack trace:

at Telerik.Web.UI.RadNumericTextBox.RangeTextProperty(String value)  
at Telerik.Web.UI.RadNumericTextBox.set_Text(String value)  
at Telerik.Web.UI.RadInputControl.LoadPostData(String postDataKey, NameValueCollection postCollection)  
at Telerik.Web.UI.RadWebControl.System.Web.UI.IPostBackDataHandler.LoadPostData(String postDataKey, NameValueCollection postCollection)  
at System.Web.UI.Page.ProcessPostData(NameValueCollection postData, Boolean fBeforeLoad)  
at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) 

None of the values are "bad". In fact, I don't even have to change anything on the row being updated. With another row already in update mode, I just click "edit" then "update" and the exception occurs. I can "edit" then "update" the row fine if no other rows are in edit mode.

Everything works fine if I remove the "ColumnEditorID" from all columns. But then it looks bad.

0
Veli
Telerik team
answered on 01 Jul 2008, 09:18 AM
Hello Scott,

Do you think you can provide us a simplified runnable project (attached to a regular support ticket), so that we can look into the matter? Once we can reproduce the misbehavior, we will be able to advise you further.

Sincerely yours,
Veli
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
Tags
Grid
Asked by
Scott
Top achievements
Rank 1
Answers by
Veli
Telerik team
Scott R
Top achievements
Rank 1
Share this question
or