jQWidgets Forums

jQuery UI Widgets Forums Grid Limit number of characters in Grid Cell

This topic contains 3 replies, has 2 voices, and was last updated by  Dimitar 11 years, 9 months ago.

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
  • Limit number of characters in Grid Cell #28596

    Vishwa
    Member

    Hi All,

    I am trying to build a web application using JQWidget API. I have a grid populated with data. User can update the data and save it. In this grid, i want to restrict the number of characters, user can enter in a perticular cell. For example, I have a column named “User Id”, In this column user should not be allowed to enter more than 8 characters.

    One solution will be to use column Validation callback method and check the length of the string and throw error message if more than 8. i.e.
    validation: function (cell, value) {
    if(typeof value == ‘undefined’ && value.length > 8){ return { result: false, message: “Not more than 8 characters allowed for User Id” };
    }
    }

    Is there any better solution for this, without writing validation call back method?

    Any pointers on this would be of great help!!

    Thanks & Regards,
    Vishwa

    Limit number of characters in Grid Cell #28624

    Dimitar
    Participant

    Hello Vishwa,

    You may achieve this by setting the cellvaluechanging callback function. E.g.:

    { text: 'First Name', columntype: 'textbox', datafield: 'firstname', width: 80,
    cellvaluechanging: function (row, datafield, columntype, oldvalue, newvalue) {
    if (newvalue.length > 8) {
    return oldvalue;
    };
    }
    },

    Best Regards,
    Dimitar

    jQWidgets team
    http://www.jqwidgets.com/

    Limit number of characters in Grid Cell #28709

    Vishwa
    Member

    Hi Dimitar,

    Thanks for providing the other alternative. But I am looking for a solution, without any callback function. I mean I don’t want, validation/cellvaluechange callback functions to be implemented for the grid cell. Any posibility of defining a property, something like “maxlength”, so that validation will be performed by the framework?

    Thanks & Regards,
    Vishwa

    Limit number of characters in Grid Cell #28736

    Dimitar
    Participant

    Hi Vishwa,

    Unfortunately, the only way to achieve this functionality is through the use of jqxGrid’s callback functions.

    Best Regards,
    Dimitar

    jQWidgets team
    http://www.jqwidgets.com/

Viewing 4 posts - 1 through 4 (of 4 total)

You must be logged in to reply to this topic.