Login  Register

Re: how to get the correct item in the model, after sorting in a repeat

Posted by lakshmipmandava on Jan 26, 2011; 4:48am
URL: https://discuss.orbeon.com/how-to-get-the-correct-item-in-the-model-after-sorting-in-a-repeat-tp43833p3237457.html

Similar way i am trying to implementing for edit feature and not working.Not able to get correct index after sorting using xxforms:sort or exsort

suggest how do i go about to fix issue

 <xhtml:table width="99%">
                                        <xhtml:tr>
                                            Date                                            Doctor Name                                            Complaint                                            Prescribed Medicines<br/>
                                                    (Name|Dosage|days)                                            Prescribed Tests                                            Action                                       </xhtml:tr>
                                        <xxforms:variable name="sorted-nodeset" select="exf:sort(instance('clinicalExamniationInstance')/consls/consl,'ConslDate','text')"/> 
                                        <xforms:repeat id="consultation" model="clinicalExaminationModel"
                                                                                nodeset="$sorted-nodeset">
                                                                                                                                    <xforms:output model="clinicalExaminationModel" ref="ConslDate"/>                                            <xforms:output model="clinicalExaminationModel" ref="Doc" />                                                                                           <xforms:output model="clinicalExaminationModel" ref="HP" class="item-amount" />
                                                                                                                                                                                              <xforms:repeat model="clinicalExaminationModel" nodeset="Medicines/Medicine">
                                                                                                                                                                                                                                                                                                                                                  </xforms:repeat>
                                                 
                                                            <xforms:output model="clinicalExaminationModel" ref="Name" class="item-amount" />
                                                         
                                                            <xforms:output model="clinicalExaminationModel" ref="Dosage" class="item-amount" />
                                                         
                                                            <xforms:output model="clinicalExaminationModel" ref="Duration" class="item-amount" />
                                                         
                                                                                                                                        <xforms:repeat model="clinicalExaminationModel" nodeset="Tests/test">
                                                                                                                                                                                                                                                                                     
                                                              <xforms:output model="clinicalExaminationModel" ref="@name" class="item-amount" />
                                                           
                                                </xforms:repeat>
                                                                                                                                        <xforms:trigger appearance="minimal">
                                                    <xforms:label><xhtml:img src="/media/icons/document_edit.png" width="20px" alt="Edit" title="Edit Consultation"/></xforms:label>
                                                    <xforms:toggle case="c022" ev:event="DOMActivate" />
                                                    <xforms:action ev:event="DOMActivate">
                                               
                                                        <xforms:setvalue ref="/lists/list[index('list')]/todo[index('todo')]/@ui:mode" value="'edit'"/>
                                                        <xforms:setvalue ref="instance('consl-num')/consl" value="index('consultation')" />
                                                        <xforms:setvalue ref="instance('consultation-index')/@val" value="index('consultation')" />
                                                        <xforms:toggle case="case-3" />
                                                    </xforms:action>
                                                </xforms:trigger>

                                                <xforms:trigger appearance="minimal">
                                                    <xforms:label><xhtml:img src="/media/img/lab.png" width="18px" alt="Test Results" title="Test Results"/></xforms:label>
                                                    <xforms:action ev:event="DOMActivate">
                                                                <xforms:setvalue ref="instance('consl-num')/consl" value="index('consultation')"/>

                                                                <xforms:setvalue ref="instance('url-container1')" value="concat('/${pageContext.request.contextPath}/strts/crmsPage?department=rheumatology&amp;pageName=lab.jsp&amp;cardId=<%= request.getParameter("cardId") %>', instance('user-name'))"/>
                                                                <xforms:setvalue ref="instance('url-container1')" value="concat(instance('url-container1'), '&amp;conslDate=')"/>
                                                                <xforms:setvalue ref="instance('url-container1')" value="concat(instance('url-container1'), instance('clinicalExamniationInstance')/consls/consl[number(instance('consl-num')/consl)]/ConslDate)"/>
                                                                <xforms:load ref="instance('url-container1')" show="replace" ev:event="DOMActivate"/>

                                                    </xforms:action>
                                                </xforms:trigger>
                                               
                                                                                        <xforms:setvalue ref="@modified" value="seconds-from-dateTime(now())" ev:event="xforms-value-changed" />
                                                                                                                                                                                            </xforms:repeat>

                                  </xhtml:table>