Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
Clear All
new posts

    URGENT neverValidate flag

    I need to know what neverValidate actually turns off - it seems the listgridfield type validation is still fired even though I have this flag set to true.

    Run the testcase. In the population field start enter 12,345 then exit edit mode. You'll see the error "Must be a whole number"

    I would remove the type property but I need this for sorting. If I don't specify that this field is an integer/decimal then it sorts as string.

    Code:
    isc.ListGrid.create({
        ID: "countryList",
        width:550, height:224, alternateRecordStyles:true, cellHeight:22,neverValidate:true,
        // use server-side dataSource so edits are retained across page transitions
        dataSource: countryDS,
        // display a subset of fields from the datasource
        fields:[
            {name:"countryCode", title:"Flag", width:40, type:"image", imageURLPrefix:"flags/16/", imageURLSuffix:".png", canEdit:false},
            {name:"countryName"},
            {name:"continent"},
            {name:"member_g8"},
            {name:"population", formatCellValue:"isc.Format.toUSString(value);"},
            {name:"independence"}
        ],
        autoFetchData: true,
        canEdit: true,
        editEvent: "click"
    })
    
     
    <DataSource
        ID="countryDS"
        serverType="sql"
        recordName="country"
        testFileName="/examples/shared/ds/test_data/country.data.xml"
    >
        <fields>
            <field name="pk"            type="integer"    hidden="true"            primaryKey="true" />
            <field name="countryCode"   type="text"       title="Code"             required="true"   />
            <field name="countryName"   type="text"       title="Country"          required="true"   />
            <field name="capital"       type="text"       title="Capital"          />
            <field name="government"    type="text"       title="Government"       length="500"      />
            <field name="continent"     type="text"       title="Continent"        >
                <valueMap>
                    <value>Europe</value>
                    <value>Asia</value>
                    <value>North America</value>
                    <value>Australia/Oceania</value>
                    <value>South America</value>
                    <value>Africa</value>
                </valueMap>
            </field>
            <field name="member_g8"     type="boolean"    title="G8"               />
            <field name="independence"  type="date"       title="Nationhood"          />
            <field name="area"          type="float"      title="Area (km&amp;sup2;)" />
            <field name="population"    type="integer"    title="Population"          />
            <field name="gdp"           type="float"      title="GDP ($M)"            />
            <field name="article"       type="link"       title="Info"            detail="true"    />
        </fields>
    </DataSource>
    Last edited by acarur01; 6 Mar 2012, 09:44.

    #2
    neverValidate disables client-side validation.
    This means that if you set the attribute, and modify a field, the client will not perform validation but will send the request to the server to save.
    However the server will still validate the field to ensure its of the expected type.

    Sounds like you have a case where you want the user to be able to enter a formatted number string (1,234 rather than 1234), but the underlying value should be numeric. If this is what you're after you should make use of a custom formatter / parser to translate from the entered string to the numeric value to save.

    Comment


      #3
      ah, found the problem - fields under dynamic forms usually do a transform in our env but we've disabled this for listgrid fields and did not catch certain scenarios. Thanks.

      Comment


        #4
        I'm revisiting a related issue where I do have neverValidate set to true but it is still validating the type. Now, unlike the previous case, users entering 1234,22 for GDP IS a valid value in French. We usually send 1234,22 over to the server and then process it for saving but we can't even get back to the server because of the validation. How can I turn off validation completely for this field? It works fine if I set neverValidate on the listgrid level

        Code:
        isc.ListGrid.create({
            ID: "countryList",
            width:550, height:224, alternateRecordStyles:true, cellHeight:22,
            // use server-side dataSource so edits are retained across page transitions
            dataSource: countryDS,
            // display a subset of fields from the datasource
            fields:[
                {name:"countryCode", title:"Flag", width:40, type:"image", imageURLPrefix:"flags/16/", imageURLSuffix:".png", canEdit:false},
                {name:"countryName"},
                {name:"continent"},
                {name:"member_g8"},
                {name:"gdp",neverValidate:true},
                {name:"independence"}
            ],
            autoFetchData: true,
            canEdit: true,
            editEvent: "click"
        })

        Comment


          #5
          You can install a parseEditorValue function so that this is turned into a valid JavaScript Number, then you don't need to turn off validation and other components that might access the value will find a Number, as expected.

          Otherwise, your field should no longer be declared as float/decimal - it's now a text field.

          Comment

          Working...
          X