0

Duplicate ID in grid

asked 2016-02-09 10:24:18 +0800

PRATIKKAR gravatar image PRATIKKAR
3 2

Hi Guys, The following piece of code is part of a grid . so it throws duplicate id exception for the second row.

<textbox hflex="1"  value="@load(each.piecePartRegVO.partChineseSpecification) @bind(each.piecePartRegVO.partChineseSpecification)" onChanging="fgid_chinese_spec.value = event.value"/>
                <textbox hflex="1" id="fgid_chinese_spec" value="@load(each.piecePartRegVO.fgidChineseSpecification) @save(each.piecePartRegVO.fgidChineseSpecification, before={'save', 'confirm'})"/>

is there any way i can generate dynamic id(fgidchinesespec) and assign it to onchange event.

Thanks Pratik

delete flag offensive retag edit

Comments

@chillworld : how to "add to the id the index of the" could you please help with this?

PRATIKKAR ( 2016-02-09 11:11:51 +0800 )edit

@chillworld: i updated as follows but still not working :

<textbox hflex="1" value="@load(each.piecePartRegVO.partChineseSpecification) @bind(each.piecePartRegVO.partChineseSpecification)" onChanging="fgidChinesespec${forEachStatus.index}.value = event.value"/>

PRATIKKAR ( 2016-02-09 12:07:31 +0800 )edit

1 Answer

Sort by ยป oldest newest most voted
0

answered 2016-02-09 10:51:48 +0800

chillworld gravatar image chillworld flag of Belgium
5367 4 9
https://github.com/chillw...

updated 2016-02-09 14:00:18 +0800

If you are working with MVVM you don't need to use the id attribute.

Let me explain what causes this issue :

You make use of <template> and inside the template you have that code.
First row creates 2 textboxes, one without id and one with id "fgid_Chinese_spec"
Now you are making a second row, again 2 textboxes and one without id and again one with id "fgid_Chinese_spec".

Because you are still in the same spaceowner you can't use that id twice.
So easiest solution is to remove id, or add to the id the index of the forEachStatus to it, like this it also stay's unique.

Edit:

id="fgid_Chinese_spec${forEachStatus.index}"

Edit 2 :

@bind stands for @load + @save so please use it correct. You are now loading the value twice.
your onChanging event will never happen as long you don't set instant="true".
This is done by default because otherwise you have a very chatty application. They update the value with the onChange event for improve performance.
But you can allow to update the value in the onChanging by just setting instant="true" in your textbox.
Like this you can remove the onChanging command also.

Your solution is actually pretty simple :

<div form="@id('fx') @load(each.piecePartRegVO) @save(each.piecePartRegVO, before={'save', 'confirm'})">        
    <label hflex="1"  value="@load(each.piecePartRegVO.partChineseSpecification)"/>
    <textbox hflex="1" value="@load(fx.fgidChineseSpecification) @save(fx.fgidChineseSpecification)"/>
</div>

Like this your label has the original value => the textbox can change but will not be persisted if you don't execute one of the 2 commands.

Greetz chill.

link publish delete flag offensive edit

Comments

did correct copy/paste error in the textbox @save

chillworld ( 2016-02-09 13:59:30 +0800 )edit
Your answer
Please start posting your answer anonymously - your answer will be saved within the current session and published after you log in or create a new account. Please try to give a substantial answer, for discussions, please use comments and please do remember to vote (after you log in)!

[hide preview]

Question tools

Follow
1 follower

RSS

Stats

Asked: 2016-02-09 10:24:18 +0800

Seen: 17 times

Last updated: Feb 09 '16

Support Options
  • Email Support
  • Training
  • Consulting
  • Outsourcing
Learn More