Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I have done some work on your problem but by adding custom validation in "PlayListApp.controller.Plays". Now the length of the 'narrative' field will not exceed 3 digits. Also user can't enter negative number.</p> <p>You have to make changes in two files :-</p> <p>1) "PlayListApp.model.Play"<br> 2) "PlayListApp.controller.Plays"</p> <pre><code> // "PlayListApp.model.Play" Ext.define("PlayListApp.model.Play", { extend: "Ext.data.Model", config: { idProperty: 'id', fields: [ { name: 'title', type: 'string' }, { name: 'narrative', type: 'int'} ], validations: [ { type: 'presence', field: 'title', message: 'Please enter a link in playlist.' },//This validation only works { type: 'presence', field: 'narrative', message: 'Please enter duration in playlist'}, { type: 'presence', field: 'narrative', message: 'Enter a number for this note.' } ] } }); </code></pre> <p>Here is the controller.js - "PlayListApp.controller.Plays"</p> <pre><code>Ext.define("PlayListApp.controller.Plays", { extend: "Ext.app.Controller", config: { refs: { // We're going to lookup our views by xtype. notesListView: "playslistview", noteEditorView: "playeditorview", notesList: "#notesList" }, control: { notesListView: { // The commands fired by the notes list container. newNoteCommand: "onNewNoteCommand", editNoteCommand: "onEditNoteCommand" }, noteEditorView: { // The commands fired by the note editor. saveNoteCommand: "onSaveNoteCommand", deleteNoteCommand: "onDeleteNoteCommand", backToHomeCommand: "onBackToHomeCommand" } } }, onSaveNoteCommand: function () { //console.log("onSaveNoteCommand"); var noteEditor = this.getNoteEditorView(); var currentNote = noteEditor.getRecord(); var newValues = noteEditor.getValues(); currentNote.set("title",newValues.title); currentNote.set("narrative", newValues.narrative); var errors = currentNote.validate(); if (!errors.isValid()) { //Ext.Msg.alert('', errors.getByField("title")[0].getMessage(), Ext.emptyFn); errors.each(function (err) { msg += err.getMessage() + '&lt;br&gt;'; }); // each() Ext.Msg.alert('ERROR!', msg); currentNote.reject(); return; } // checking for negative number if(newValues.narrative&lt;="0") { Ext.Msg.alert('','Choose number greater than 0'); currentNote.reject(); return; } // checking for value greater than 3-digit number if(newValues.narrative&gt;"999") { Ext.Msg.alert('','Length should not be greater than THREE'); currentNote.reject(); return; } var notesStore = Ext.getStore("Notes"); //notesStore.sync(); //notesStore.sort([{ property: 'dateCreated', direction: 'DESC'}]); this.activateNotesList(); }, </code></pre> <p>Hope this helps you.<br> If this is not what you wanted , explain your requirement once again.<br> Bye.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload