Announcement

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

    ValuesManager getting error

    Hello,

    In the sample code, if i add date object to dynamic form, When " this.vwo.valManager.addMember(this.vwo.FrmDuzelt1);" command runs, giving the log "Uncaught TypeError: Cannot read property 'getSavedItemValue' of null "
    giving same log when “this.vwo.FrmDuzelt1.setValuesManager(this.vwo.valManager);”

    How do I fix this error?


    sample code:

    isc.ClassFactory.defineClass("TestForm", isc.VLayout);
    isc.TestForm.addProperties({
    height: "100%",
    width: "100%",
    showResizeBar: false,
    autoDraw: false,
    //---
    vwObjects: {},
    treeObj: {},
    setForm: function () {
    mainLayout: this;
    var dsFields = [
    { name: "ID", title: "Id Key", primaryKey: true },
    { name: "DOGTAR", title: "Doğum Tarihi", type: "date" },
    { name: "ADSAD", title: "Adı Soyadı" }
    ];

    dsOperationBindings = [];
    dsOperationBindings.push({ operationType: "fetch", dataProtocol: "postMessage", dataURL: "../CRUD/GetData" });
    dsOperationBindings.push({ operationType: "remove", dataProtocol: "postMessage", dataURL: "../CRUD/DeleteData" });
    dsOperationBindings.push({ operationType: "add", dataProtocol: "postMessage", dataURL: "../CRUD/InsertData" });
    dsOperationBindings.push({ operationType: "update", dataProtocol: "postMessage", dataURL: "../CRUD/UpdateData" });
    dsOperationBindings.push({ operationType: "validate", dataProtocol: "postMessage", dataURL: "../CRUD/ValidateData" });

    this.vwObjects.ds = isc.RestDataSource.create({
    dataFormat: "json",
    fields: dsFields,
    criteriaPolicy: "dropOnChange",
    jsonPrefix: "//'"]]>>isc_JSONResponseStart>>",
    jsonSuffix: '//isc_JSONResponseEnd',
    operationBindings: dsOperationBindings,
    validateRelatedRecords: true,
    transformResponse: function (dsResponse, dsRequest, data) {
    var dsResponse = this.Super("transformResponse", arguments);
    // ... do something to dsResponse ...
    return dsResponse;
    },
    transformRequest: function (dsRequest) {

    // modify dsRequest.data here, for example, add fixed criteria

    if (!dsRequest.data) {
    dsRequest.data = {};
    }
    dsRequest.data.programName = "dem201";
    dsRequest.data.programDataSource = "L_CARMASF";
    return this.Super("transformRequest", arguments);
    },
    handleError: function (response, request) {
    if (response.data) {
    isc.Dialog.create({
    message: "<b>" + status[response.status.toString()] + ": " + response.data.MainMessage + "<br><br>Hata Detayı:<br></b>" + response.data.Details,
    icon: "../../Images/System/error.png",
    isModal: true,
    title: "UYARI",
    buttons: [
    isc.Button.create({ title: "OK" }),
    ],
    buttonClick: function (button, index) {
    this.destroy();
    }
    });
    return false;
    }
    return true;
    }
    });

    this.vwObjects.tmpGrid = isc.ListGrid.create({
    vwo: this.vwObjects,
    autoDraw: false,
    fields: dsFields,
    alternateRecordStyles: true,
    autoFitFieldWidths: true,
    width: "100%",
    height: "100%",
    dataSource: this.vwObjects.ds
    });


    this.vwObjects.tmpButton = isc.IButton.create({
    vwo: this.vwObjects,
    autoDraw: false,
    title: "Görüntüle",
    width: 150,
    click: function () { this.vwo.tmpGrid.fetchData(); }
    });



    this.vwObjects.tmpButton2 = isc.IButton.create({
    vwo: this.vwObjects,
    autoDraw: false,
    title: "Düzelt",
    width: 150,
    click: function () {

    if (!this.vwo.valManager) {
    this.vwo.valManager = isc.ValuesManager.create({
    dataSource: this.vwo.ds
    });
    }

    var tmpRecord = this.vwo.tmpGrid.getSelectedRecord();
    //this.vwo.FrmDuzelt1.setValuesManager(this.vwo.valManager);
    this.vwo.tmpForm.setValuesManager(this.vwo.valManager);
    if (tmpRecord) {
    this.vwo.tmpForm.setVisibility("visible");
    this.vwo.valManager.editRecord(tmpRecord);
    this.vwo.tmpGrid.setShowResizeBar(true);
    }

    }
    });

    this.vwObjects.tmpForm = isc.DynamicForm.create({
    vwo: this.vwObjects,
    width: 400,
    visibility: "hidden"
    });

    var tmpObj = FormObjects["Date"]();
    tmpObj.addProperty("name", "DOGTAR");
    tmpObj.addProperty("title", "Doğum Tarihi");
    this.vwObjects.field1 = tmpObj.getObj(this.vwObjects); //{ name: "DOGTAR", title: "Doğum Tarihi", type: "date", useTextField: true };


    this.vwObjects.field2 = { name: "ADSAD", title: "Adı Soyadı" };

    this.vwObjects.tmpForm.addField(this.vwObjects.field1);
    this.vwObjects.tmpForm.addField(this.vwObjects.field2);



    this.addMember(this.vwObjects.tmpButton);
    this.addMember(this.vwObjects.tmpButton2);
    this.addMember(this.vwObjects.tmpButton3);
    this.addMember(this.vwObjects.tmpGrid);
    this.addMember(this.vwObjects.tmpForm);

    },



    initWidget: function () {
    this.Super("initWidget", arguments);
    this.setForm();
    this.draw();
    }
    });

    var tmpForm = isc.TestForm.create();

    #2
    Your code has at least one syntax error - fixing the first line of your setForm() method may fix your problem.

    If not, check for similar syntax errors - that is, make sure the code is actually compiling, so we can run it. Then, repost it and we can take a look.

    Comment


      #3

      Hello,

      I fixed syntax errors you said and

      I created a test program have two buttons. "Get Data List" button fill the grid. When click "Edit" button, create valuemanager and set to dynamic form.

      When add "BDATE" to dynamicform ("vwObjects.tmpForm") and call "this.vwo.tmpForm.setValuesManager(this.vwo.valManager);" getting error.

      But don't add "BDATE" to dynamicForm run succesfuly.

      //----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

      isc.ClassFactory.defineClass("TestForm", isc.VLayout);

      isc.TestForm.addProperties({
      height: "100%",
      width: "100%",
      showResizeBar: false,
      autoDraw: false,
      //---
      vwObjects: {},
      treeObj: {},
      clientData: [{ ID: 17, BDATE: "01.03.2050", UNAME: "Mad Max" },
      { ID: 17, BDATE: "01.03.1975", UNAME: "John Wick" }],

      setForm: function () {
      mainLayout: this;
      var dsFields = [
      { name: "ID", title: "Id Key", primaryKey: true },
      { name: "BDATE", title: "Birth Date", type: "date" },
      { name: "UNAME", title: "Name" }
      ];

      this.vwObjects.ds = isc.DataSource.create({
      clientOnly: true,
      canDragRecordsOut: true,
      canAcceptDroppedRecords: true,
      dragDataAction: "copy",
      fields: dsFields,
      testData: this.clientData
      });


      this.vwObjects.tmpGrid = isc.ListGrid.create({
      vwo: this.vwObjects,
      autoDraw: false,
      fields: dsFields,
      alternateRecordStyles: true,
      autoFitFieldWidths: true,
      width: "100%",
      height: "100%",
      dataSource: this.vwObjects.ds
      });


      this.vwObjects.tmpButton = isc.IButton.create({
      vwo: this.vwObjects,
      autoDraw: false,
      title: "Get Data List",
      width: 150,
      click: function () { this.vwo.tmpGrid.fetchData(); }
      });



      this.vwObjects.tmpForm = isc.DynamicForm.create({
      vwo: this.vwObjects,
      width: 400,
      visibility: "hidden"
      });

      this.vwObjects.tmpButton2 = isc.IButton.create({
      vwo: this.vwObjects,
      autoDraw: false,
      title: "Edit",
      width: 150,
      click: function () {

      var tmpRecord = this.vwo.tmpGrid.getSelectedRecord();

      if (!this.vwo.valManager) {
      this.vwo.valManager = isc.ValuesManager.create({
      dataSource: this.vwo.ds
      });
      this.vwo.tmpForm.setValuesManager(this.vwo.valManager);
      }

      if (tmpRecord) {
      this.vwo.tmpForm.setVisibility("visible");
      this.vwo.valManager.editRecord(tmpRecord);
      this.vwo.tmpGrid.setShowResizeBar(true);
      }

      }
      });

      this.vwObjects.field1 = { name: "BDATE", title: "Birth Date", type: "date", useTextField: true, vwo : this.vwObjects }; //tmpObj.getObj(this.vwObjects);

      this.vwObjects.field2 = { name: "UNAME", title: "Name" , vwo: this.vwObjects};

      this.vwObjects.tmpForm.addField(this.vwObjects.field1);
      this.vwObjects.tmpForm.addField(this.vwObjects.field2);



      this.addMember(this.vwObjects.tmpButton);
      this.addMember(this.vwObjects.tmpButton2);
      this.addMember(this.vwObjects.tmpGrid);
      this.addMember(this.vwObjects.tmpForm);

      },

      initWidget: function () {
      this.Super("initWidget", arguments);
      this.setForm();
      this.draw();
      }
      });

      var tmpForm = isc.TestForm.create();

      Comment


        #4
        Any field that is of type "date" should have an actual JavaScript Date instance as it's value, not a String.

        For more background information on how date, time and datetime values are handled, read the Date and Time Format and Storage overview.

        Comment


          #5
          i changed clientData like this

          clientData: [{ ID: 17, BDATE: new Date(1776, 05, 11), UNAME: "Mad Max" },
          { ID: 17, BDATE: new Date(1776, 05, 11), UNAME: "John Wick" }]

          but when i called "this.vwo.tmpForm.setValuesManager(this.vwo.valManager);" gives error in console.

          i think, it isn't date format problem because grid is working correct.

          console error is Uncaught TypeError: Cannot read property 'getDataSource' of null in ISC_Core.js:1723.

          http://i.hizliresim.com/9oX6BZ.jpg
          http://i.hizliresim.com/qMqgXZ.jpg

          Last edited by eakduman; 24th Feb 2016, 00:16.

          Comment


            #6
            The switch to use actual Date instances is a necessary correction to your code, that's why the error is now different.

            Here are some other issues:

            1. addField() is not a public API

            2. you can't add a DynamicForm to a ValuesManager that has a DataSource unless the DynamicForm also has a DataSource

            Please do audit any code you post for basic issues like this - we're really here to help you with actual framework issues. It's no problem if some subtle usage issue comes up, but it's not appropriate to submit obviously invalid code 3 times in a row and ask us to troubleshoot it - we have our (hourly) Consulting offering if you are looking for someone to troubleshoot your application code, even when there is no possible framework issue involved.

            Also, please put CODE tags around your code to avoid it becoming unreadable (all indentation lost).

            Comment

            Working...
            X