Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
15
unbound column update formula only works for the first unbound column when adding new row
posted

Hi

I am using infragistics iggrid jquery apis to build a grid to show some data, and below is how I set the iggrid, and strangely enough, the formula only works with the first unbound column when I add a new row, and formula of the other two unbound column doesn't get called, could someone help me with the problem?when insert a new row, only the first formula get called

        var grid = $("#Grid").igGrid({
          width: "80%",
          autoGenerateLayouts: false,
          autoGenerateColumns: false,
          primaryKey: "name",
          columns: [
            {
              headerText: "Display Name",
              key: "displayName",
              dataType: "string",
              width: "15%",
            },
            {
              headerText: "Name",
              key: "name",
              dataType: "string",
              width: "15%",
            },
            {
              headerText: "Weeks",
              key: "weeks",
              dataType: "number",
              width: "10%",
            },
            {
              headerText: "Absence Week",
              key: "absenceWeeks",
              dataType: "number",
              width: "10%",
            },
            {
              headerText: "Slack Time",
              key: "slackTime",
              dataType: "number",
              width: "10%",
            },
            {
              headerText: "Allocated",
              key: "allocated",
              dataType: "number",
              unbound: true,
              formula: function CalculateAllocated(data, grid) {
                let name = data['name'];
                let contributorList = Object.keys(contributorPointsJson)
                console.log(contributorList)

                if (contributorList.includes(name)) {
                  points = contributorPointsJson[name];
                  return contributorPointsJson[name];
                } else {
                  return 0;
                }
              },
              width: "10%",
            },
            {
              headerText: "Available",
              key: "available",
              dataType: "number",
              unbound: true,
              formula: function CalculateAvailable(data, grid) {
                return (data["weeks"] - data["absenceWeeks"]) * (1 - data["slackTime"])
              },
              width: "10%",
            },
            {
              headerText: "Remaining",
              key: "remaining",
              dataType: "number",
              unbound: true,
              formula: function CalculateRemaining(data, grid) {
                return data["available"] - data["allocated"]
              },
              width: "10%",
            },
          ],
          features: [
            {
              name: "Updating",
              rowAdded: function (e, ui) {
                $("#undo").igButton("option", "disabled", false);
                $("#saveChanges").igButton("option", "disabled", false);
              },
              rowDeleted: function (e, args) {
                $("#undo").igButton("option", "disabled", false);
                $("#saveChanges").igButton("option", "disabled", false);
              },
              editRowEnded: function (e, ui) {
                if (ui.update) {
                  $("#undo").igButton("option", "disabled", false);
                  $("#saveChanges").igButton("option", "disabled", false);
                }
              },
              enableAddRow: true,
              editMode: "row",
              enableDeleteRow: true,
              columnSettings: [
                {
                  columnKey: "available",
                  readOnly: true,
                },
                {
                  columnKey: "allocated",
                  readOnly: true,
                },
                {
                  columnKey: "remaining",
                  readOnly: true,
                },
              ],
            },
          ],
          restSettings: {
            create: {
              url: "/api/developers/{{currentSprint}}",
              batch: true,
            },
            update: {
              url: "/api/developers/{{currentSprint}}",
              batch: true,
            },
            remove: {
              url: "/api/developers/{{currentSprint}}",
              batch: true,
            },
          },
          dataSource: developerJson,
          dataSourceType: "json",
        });
      });