PSolano
PSolano

Reputation: 398

How can I make a dojox.form.Raiting readOnly

I have a requirement where users need to rate a response; for this I'm trying dojox.form.Rating widget.

This works fine so far, but, I need to provide a readonly average rating as well.

I have tried disabled=true or disabled=disabled according to http://dojotoolkit.org/api/, but, it is not working.

I also tried wrapping this div within a xp:panel with ReadOnly property and still I'm able to select a value from it.

<div id="rateControl" dojoType="dojox.form.Rating" numStars="5"
            disabled="true" value="2" class="pull-right">
</div>

Upvotes: 0

Views: 188

Answers (2)

Serdar Basegmez
Serdar Basegmez

Reputation: 3355

As Michael commented, it doesn't respect "disabled" attribute and patched Rating widget does not exist in the dojo library shipped by Domino server.

In my xInvolve project, I have used the dojo Rating widget. For read-only, I have just implemented a repeat control within a div. You can see the code in the XSnippets project.

<xp:div id="ratingReadonly"
    styleClass="ratingStarWrapper">
    <xp:this.rendered><![CDATA[#{javascript:(! invTools.isRatingEnabled(compositeData))}]]></xp:this.rendered>
    <xp:repeat id="repeat1" first="0"
        indexVar="starIndex" rows="100" var="starType"
        style="display:inline">
        <xp:this.value><![CDATA[#{javascript:invTools.getRepeatArray(compositeData)}]]></xp:this.value>
        <xp:image id="image2">
            <xp:this.url><![CDATA[#{javascript:"/.ibmxspres/dojoroot/dojox/form/resources/images/rating_"+starType+".gif"}]]></xp:this.url>
        </xp:image>
    </xp:repeat>
</xp:div><!-- end-ratingReadonly -->

Here, invTools.getRepeatArray(compositeData) contains the number of 'full' and 'empty' stars. e.g. for 3/5 stars, it is ['full', 'full', 'full', 'empty', 'empty']

Upvotes: 1

Michael Saiz
Michael Saiz

Reputation: 1640

Hi there is a bug with the dojox.form.Raiting, see the bugs.dojo: Instead of the patch you could use a Workaround you could use a overlay div wich is rendered when the control should be readonly:

<xp:panel id="container">
<xp:panel id="overlay" style="width: 100%;  height: 100%;   position: absolute;   top: 0;   left: 0; z-index: 10;"></xp:panel>
    <div
            id="rateControl"
            dojoType="dojox.form.Rating"
            numStars="5"
            value="2"
            class="pull-right">
    </div>
</xp:panel>

Upvotes: 0

Related Questions