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

[Solved] Currency Text Box - Sub Grid Edit Problem

12 Answers 175 Views
Grid
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Jigar
Top achievements
Rank 1
Jigar asked on 02 Oct 2010, 05:30 PM
Hi,

I am using Master / Detail Grid. I have currency text box in both grid's model class. Now When I click on Edit button; edit form popup appears fine for the first time. But when I click edit button again in sub grid pop-up doesn't appear. Telerik.grid.editing.js gives error ($(element).data('tTextBox') is null ).

If I remove DataType(DataType.Currency) from Amount field in model; it works fine. Is it a bug?

You can find sample project here.
http://cid-6a5cc75567684728.office.live.com/browse.aspx/.Public

Thanks in Advance,

Jigar.

12 Answers, 1 is accepted

Sort by
0
Rosen
Telerik team
answered on 04 Oct 2010, 08:51 AM
Hi Jigar,

The error you are getting is cause by the fact that edit template is shown for two properties with same names on a single page. This will result in two html elements rendered with same ID, which as you may know is invalid. Therefore, please ensure a valid html is outputted when edit template is rendered. 

Best wishes,

Rosen
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
Jigar
Top achievements
Rank 1
answered on 04 Oct 2010, 09:29 AM
Hi Rosen,

Thanks a lot for you answer.

I do agree that component having same name on the page Can cause a problem;
1. But I used two different models and those should be rendered differently.
2. In sample project; I changed the amount field name like for class NumericTestA, it's amounta and for NumericTestB it's amountb; Still the problem is there.

Thanks,

Jigar.

0
Jigar
Top achievements
Rank 1
answered on 04 Oct 2010, 09:31 AM
Hi Rosen,

Oops my first comment is wrong; as I am using ajax binding.

Regards
Jigar.
0
Jigar
Top achievements
Rank 1
answered on 04 Oct 2010, 09:38 AM
Hi Rosen,

I think I came to know the reason for this; As there is a sub grid for each row in master grid; each editor template for such sub grid shall be rendered with same field name. This may the place where it doesn't go as expected, Am I right?

If so then why is it with currency text box only? ( though I have not tested it for numeric / percent / integer text box ). I am using sub grid for Country, State, City tables and I didn't face such problem there.

Thanks,

Jigar.
0
Rosen
Telerik team
answered on 04 Oct 2010, 09:54 AM
Hi Jigar,

Regular textBoxes will not fail, as there is no javascript attached to them. In your scenario, the actual error is caused by the fact that the jQuery selector cannot locate the correct element as there a two with this ID on the page.

Regards,
Rosen
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
Jigar
Top achievements
Rank 1
answered on 04 Oct 2010, 10:10 AM
Hi Rosen,

Thank you.

Can you please suggest a work around for it? Because there will be a same model for each sub grid. And I tested it for percent and integer text box for both of them issue is same.

Thanks.

Jigar
0
Rosen
Telerik team
answered on 04 Oct 2010, 03:42 PM
Hello Jigar,

A possible workaround will be changing the names of inner grid's ViewModel properties.
 
Regards,
Rosen
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
Jigar
Top achievements
Rank 1
answered on 04 Oct 2010, 03:48 PM
Hi Rosen,

I tried that too, you may have a look at the sample project I gave, If you change the Name of the amount field to amountb in Sub Grid model i.e. NumericTestB. The problem is still there.

And it's obvious because of the reason you explained. For Example: In case of sub grid there are multiple grids like SubGrid_1, SubGrid_2, ....., SubGrid_N but all these grids render same currency text box filed i.e. amountb.

I hope I explained it correctly.

Thanks & Regards,

Jigar.
0
BaiH
Top achievements
Rank 1
answered on 05 Oct 2010, 07:33 AM
Hey Jigar,

I'm not sure if this will help but you can try generating/assigning a different id for each instance of the edit template... using a GUID maybe or similar.

--BH
0
Jigar
Top achievements
Rank 1
answered on 05 Oct 2010, 07:42 AM
Hi Baih,

Can you please elaborate What exactly you mean by different editor template GUID, and How can it help to identify the unique component? Because it will more depend on how this component's java script call them?

I guess javascript accessing these components with it's name ( rather than like "this" keyword) and this is what is creating the problem in case of sub grids.

Regards,

Jigar.

0
BaiH
Top achievements
Rank 1
answered on 05 Oct 2010, 07:56 AM
Basically what I'm saying is that you should *somehow* generate a different id for the  component/html element rendered by the editor template. How to do that... use a timestamp, Guid, or maybe some more appropriate (predictable) algorithm.
0
Jigar
Top achievements
Rank 1
answered on 07 Oct 2010, 06:04 AM
Hi BaiH,

thanks for your reply.

But there are few problems
1. My editor template renders using EditorForModel, so it will automatically get the field names from the model.
2. If at all Somehow I manage to do what you suggested; the problem will arise while creating / editing the the records; because Model Class and tables are being automap, I am not doing it manually.

Possible solution can be,
1. I need to generate unique name for each component for all the sub grids being rendered as you suggested;
2. While posting it; It should post the data as per it's original name.

Observations:
1. I also tested this scenario for DropDownList; If I click on any sub grid (For Ex. SubGrid_1) edit button in editor template DropDownList works fine but when I click on Edit button on another sub grid ( for Ex. SubGrid_2 ) drop down list won't work. This may be because of the same problem.

2. In new release (SP1 - 930) telerik.grid.editing.js gives clear error because of this problem and this may prevent javascript to execute further in IE. Though I have not tested it; will test it and confirm the same.

Thanks & Regards,

Jigar.



 

Tags
Grid
Asked by
Jigar
Top achievements
Rank 1
Answers by
Rosen
Telerik team
Jigar
Top achievements
Rank 1
BaiH
Top achievements
Rank 1
Share this question
or