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

[Solved] NumberFormat.AllowRounding is null or not an object

7 Answers 219 Views
Grid
This is a migrated thread and some comments may be shown as answers.
MarkInTexas
Top achievements
Rank 1
MarkInTexas asked on 23 Mar 2009, 02:52 PM
I have ran into a problem that I cannot figure out.

I have 2 controls in a template column of a RadGrid.
An ASP textbox (tried also RadTextBox) and a RadNumericTextbox.

I am getting a Javascript error for NumberFormat.
Error : 'NumberFormat.AllowRounding' is null or not an object

I have tried declaring ALL properties but that does not seem to change the behavior. And I get the get the error sometimes on AllowRounding, DecimalSeperator and DecimalSeperator. I added the declaration to the NumberFormat for each exception that has occurred but that did not the issue.

I am using SelfReferencingHierachy based on the example of Self Referencing Hierarchy in the Demo's Section.

Here is my MasterTableView declaration
        <MasterTableView    
          HierarchyDefaultExpanded="True" HierarchyLoadMode="Client"   
          Width="100%" 
          EditMode="inline" DataKeyNames="Id,ParentId,Name" > 
          
          <SelfHierarchySettings ParentKeyName="ParentId" KeyName="Id"  /> 
          <Columns> 
              
            <telerik:GridBoundColumn DataField="Name" HeaderText="Name" UniqueName="Name" ReadOnly="true">  
              <HeaderStyle Width="150px" /> 
            </telerik:GridBoundColumn> 
              
            <telerik:GridTemplateColumn UniqueName="Value" HeaderText="Value" DataField="Value">  
              <HeaderStyle Width="100px" /> 
              <ItemTemplate> 
                  
                  <asp:TextBox ID="stringValue" runat="Server" Visible="false" /> 
                  <telerik:RadNumericTextBox ID="intValue" runat="Server" Skin="RxLink" EnableEmbeddedSkins="false" Visible="false" SelectionOnFocus="SelectAll">  

                      <NumberFormat DecimalDigits="0" AllowRounding="false" KeepNotRoundedValue="true" DecimalSeparator="." />

 

  

 

                  </telerik:RadNumericTextBox> 
              </ItemTemplate> 
            </telerik:GridTemplateColumn> 
            
          </Columns> 
        </MasterTableView> 
 

Here is the script that is getting the exception
NumberFormat.Round=function(_1,_2){  
if(!_2.NumberFormat.AllowRounding){  
return _1;  
}  
 

How can I fix or work-around this issue? Do you need more information?

Thanks,
Mark.

7 Answers, 1 is accepted

Sort by
0
MarkInTexas
Top achievements
Rank 1
answered on 23 Mar 2009, 03:01 PM
It might be help to include the DataBound code.

Note: I just added setting the NumberFormat properties in C# code below and still get the exception.

      protected void propertyEditor_ItemDataBound(object sender, GridItemEventArgs e)  
      {  
          CreateExpandCollapseButton(e.Item, "Name");  
 
          if(e.Item is GridEditableItem)  
          {  
            ClassProperty data = e.Item.DataItem as ClassProperty;  
 
            switch(data.ValueType)  
            {  
              case ClassProperty.ValueTypesE.NoValue:  
                // no value   
                break;  
 
              case ClassProperty.ValueTypesE.String:  
                TextBox txtBox = (e.Item as GridEditableItem)["Value"].FindControl( "stringValue" ) as TextBox;  
                txtBox.Text = (String) data.Value;  
                txtBox.Visible = true;  
                break;  
 
              case ClassProperty.ValueTypesE.Integer:  
                RadNumericTextBox intBox = (e.Item as GridEditableItem)["Value"].FindControl( "intValue" ) as RadNumericTextBox;  
                intBox.Value = (int) data.Value;  
                intBox.NumberFormat.DecimalDigits = 0;  
                intBox.NumberFormat.AllowRounding = false;  
                intBox.NumberFormat.DecimalSeparator = ".";  
                intBox.MinValue = 0;  
                  
                intBox.Visible = true;  
                break;  
 
              default:  
                break;  
            }  
          }  
      }  
 
0
MarkInTexas
Top achievements
Rank 1
answered on 23 Mar 2009, 04:38 PM
I noticed my MasterView declaration is using ItemTemplate and did not have an EditTemplate and I though maybe that was causing the exception.

Here is an updated declaration for this MasterView. Even with an ItemTemplate and EditTemplate I am still getting the same exceptions. I have tried editing in both "Pop-up" and "InPage".

Still getting the exception.

        <MasterTableView    
          HierarchyDefaultExpanded="True" HierarchyLoadMode="Client"   
          Width="100%"   
          EditMode="InPlace" DataKeyNames="Id,ParentId,Name" > 
          <SelfHierarchySettings ParentKeyName="ParentId" KeyName="Id"  /> 
            
          <Columns> 
            <telerik:GridBoundColumn DataField="Name" HeaderText="Name" UniqueName="Name" ReadOnly="true">  
              <HeaderStyle Width="150px" /> 
            </telerik:GridBoundColumn> 
              
            <telerik:GridTemplateColumn UniqueName="Value" HeaderText="Value" DataField="Value">  
              <HeaderStyle Width="100px" /> 
              <ItemTemplate> 
                <asp:Label ID="lblValue" runat="server" /> 
              </ItemTemplate> 
                 
              <EditItemTemplate> 
                  
                    
                  <telerik:RadNumericTextBox ID="intValue" runat="Server" Skin="MySkin" EnableEmbeddedSkins="false" Visible="false" SelectionOnFocus="SelectAll">  
                    <NumberFormat DecimalDigits="0"  AllowRounding="false" KeepNotRoundedValue="true" DecimalSeparator="." /> 
                    <IncrementSettings InterceptArrowKeys="true" InterceptMouseWheel="true"/>  
                  </telerik:RadNumericTextBox> 
 
                  <telerik:RadTextBox ID="stringValue" runat="Server" Skin="MySkin" EnableEmbeddedSkins="false" Visible="false" SelectionOnFocus="SelectAll">  
                  </telerik:RadTextBox> 
              </EditItemTemplate> 
            </telerik:GridTemplateColumn> 
          </Columns> 
        </MasterTableView> 
 


0
MarkInTexas
Top achievements
Rank 1
answered on 25 Mar 2009, 04:06 PM
This issue is still unresolved.

Any help is greatly appreciated.

Thanks,
Mark.
0
Iana Tsolova
Telerik team
answered on 26 Mar 2009, 08:46 AM
Hello crownmark,

Could you please try modifying your server code as below and see if it makes any difference:

protected void propertyEditor_ItemDataBound(object sender, GridItemEventArgs e)     
      {     
          CreateExpandCollapseButton(e.Item, "Name");     
    
          if(e.Item is GridEditableItem && e.Item.IsInEditMode)     
          {     
            ClassProperty data = e.Item.DataItem as ClassProperty;     
    
            switch(data.ValueType)     
            {     
              case ClassProperty.ValueTypesE.NoValue:     
                // no value      
                break;     
    
              case ClassProperty.ValueTypesE.String:     
                TextBox txtBox = (e.Item as GridEditableItem)["Value"].FindControl( "stringValue" ) as TextBox;     
                txtBox.Text = (String) data.Value;     
                txtBox.Visible = true;     
                break;     
    
              case ClassProperty.ValueTypesE.Integer:     
                RadNumericTextBox intBox = (e.Item as GridEditableItem)["Value"].FindControl( "intValue" ) as RadNumericTextBox;     
                intBox.DbValue = (int) data.Value;     
                intBox.NumberFormat.DecimalDigits = 0;     
                intBox.NumberFormat.AllowRounding = false;     
                intBox.NumberFormat.DecimalSeparator = ".";     
                intBox.MinValue = 0;     
                     
                intBox.Visible = true;     
                break;     
    
              default:     
                break;     
            }     
          }     
      }     
 

Find more about data binding RadNumericTextBox here.

Let me know if this helps.

Best wishes,
Iana
the Telerik team

Check out Telerik Trainer , the state of the art learning tool for Telerik products.
0
MarkInTexas
Top achievements
Rank 1
answered on 27 Mar 2009, 07:31 PM
Thanks for help. I updated to the lastest build (324) and now that problem is gone away with no changes to my code and using the "lastest build".

However....

Now getting another script error.

"Microsoft JScript runtime error: Object doesn't support this property or method"


From debugger :

 

case Sys.Browser.InternetExplorer:Sys.UI.DomElement.getLocation=function   
Sys$UI$DomElement$getLocation(a){if(a.self||a.nodeType===9)return new   
Sys.UI.Point(0,0);var d=a.getClientRects();<BR><BR

Note that "a" is not defined and the source of the error I am guessing.

 

To Review: Issue original posted is now gone, but now have a different script error. Only changes made were updating to the latest build.

BTW: I did try the above suggestions and did not help or change the original error. Also tried above suggestions with "Latest" build and get the above script error with or without the suggested changes.

What else can I try? Any other work-arounds? I will keep my out for the next build and try that as well.

Thanks for your help,
Mark.

 

0
Accepted
Iana Tsolova
Telerik team
answered on 31 Mar 2009, 12:09 PM
Hello crownmark,

I suggest that you open a formal support ticket and send me a runnable sample illustrating the unexpected errors. Thus I could debug it locally and do my best in order to find a resolution for you.

Let me know if this works for you.

Kind regards,
Iana
the Telerik team

Check out Telerik Trainer , the state of the art learning tool for Telerik products.
0
MarkInTexas
Top achievements
Rank 1
answered on 01 Apr 2009, 02:11 AM
Thanks,

Sounds good, I will see if I can get a sample project that duplicates the error.

Mark.
Tags
Grid
Asked by
MarkInTexas
Top achievements
Rank 1
Answers by
MarkInTexas
Top achievements
Rank 1
Iana Tsolova
Telerik team
Share this question
or