Skip to Content
author's profile photo Former Member
Former Member

Binding rows aggregation for Planning Calendar

Hi,

In my controller, I am creating a named model on the PlanningCalendar control and trying to bind the rows aggregation's path.


var oModel = this.getOwnerComponent().getModel().oData;
var oFilteredModel = {};
for(var key in oModel) {
  if(oModel.hasOwnProperty(key)) {
     var obj = oModel[key];
     var startDate = obj.StartDate
     var finishDate = obj.FinishDate;
     //this is a general purpose filter, I need to know what you are sending when you send   //a date value to finishdate with no value   if(startDate  && finishDate) {
     oFilteredModel[key] = obj;
   }
 }
}var oNewModel = new JSONModel({WorkOrderDetailSet:oFilteredModel});
console.log(oNewModel);
var oCalendar = this.getView().byId("PC1");
oCalendar.setModel(oNewModel,"calendar_model");
                         oCalendar.bindAggregation("rows",{path:"calendar_model/>WorkOrderDetailSet"});

This is my view layer:

<PlanningCalendar id="PC1" startDate="{FinishDate}" rows="{path: 'calendar_model>/WorkOrderDetailSet'}" appointmentSelect="handleAppointmentSelect" rowSelectionChange="handleAppointmentSelect">

<toolbarContent>

<Title text="Work Orders Timeline" titleStyle="H4"/>

</toolbarContent>

<rows>

<PlanningCalendarRow title="{WorkorderNo}" text="{WorkorderText}" >

<appointments>

<u:CalendarAppointment startDate="{StartDate}" endDate="{FinishDate}">

</u:CalendarAppointment>

</appointments>

</PlanningCalendarRow>

</rows>

</PlanningCalendar>

However, I get an error when executing this code that says:

Uncaught Error: Missing template or factory function for aggregation rows of Element sap.m.PlanningCalendar#__component0---worklist--PC1

I would ideally like to do the binding in the XML view itself but that does not seem to be possible. If that is not possible, I would like to bind the aggregation path in the view leaving the template to be bound in the xml view.

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

1 Answer

  • Posted on Jul 28, 2016 at 03:46 AM

    Hi Vamsi,

    Actually, it should work when you just update the model, no need to bind rows again. Since, JSON is a two way model.

    If you want to go ahead with bindAggregation method, then you can try something like this:

    oCalendar.bindAggregation("rows", {path: "calendar_model/>WorkOrderDetailSet", template: oCalendar.getRows()[0].clone()});
    

    Regards,

    Sai.

    Add a comment
    10|10000 characters needed characters exceeded

    • Former Member

      Hi Sai,

      I got a big fat error message that looked like this:

      During a clone operation, a template was found that neither was marked with 'templateShareable:true' nor 'templateShareable:false'. The framework won't destroy the template. This could cause errors (e.g. duplicate IDs) or memory leaks (The template is used in aggregation 'appointments' of object '__row0').For more information, see documentation under 'Aggregation Binding'

      In my controller, I added the templateShareable to the binding, something like this:

      var oModel = this.getOwnerComponent().getModel().oData;

      var oFilteredModel = {

      WorkOrderDetailSet:[]

      };

      for(var key in oModel) {

      if(oModel.hasOwnProperty(key)) {

      var obj = oModel[key];

      var StartDate = obj.StartDate;

      var FinishDate = obj.FinishDate;

      var WorkorderNo = obj.WorkorderNo;

      var WorkorderText = obj.WorkorderText;

      //this is a general purpose filter, I need to know what you are sending when you send

      //a date value to finishdate with no value

      if(StartDate && FinishDate) {

      oFilteredModel.WorkOrderDetailSet.push({

      confirmations:[

      {

      StartDate:StartDate,

      FinishDate:FinishDate

      }

      ],

      WorkorderNo:WorkorderNo,

      WorkorderText:WorkorderText

      });

      }

      }

      }

      var oNewModel = new JSONModel(oFilteredModel);

      var oCalendar = this.getView().byId("PC1");

      oCalendar.setModel(oNewModel,"calendar_model");

      var oTemplate = oCalendar.getRows()[0].clone();

      oCalendar.bindAggregation("rows", {

      path:"calendar_model/>WorkOrderDetailSet",

      template: oTemplate,

      templateShareable:false

      });

      I changed my data model to something that looks like this:

      {

      WorkOrderDetailSet:[

      {

      WorkorderNo,

      WorkorderText,

      confirmations:[

      {

      StartDate,

      FinishDate

      }

      ]

      }

      ]

      }


      I added the confirmations to the appointments aggregation and the view looks like this:

      <PlanningCalendar id="PC1" startDate="{FinishDate}" rows="{path: '/WorkOrderDetailSet'}" appointmentSelect="handleAppointmentSelect" rowSelectionChange="handleAppointmentSelect">

      <toolbarContent>

      <Title text="Work Orders Timeline" titleStyle="H4"/>

      </toolbarContent>

      <rows>

      <PlanningCalendarRow appointments="{confirmations}" title="{WorkorderNo}" text="{WorkorderText}" >

      <appointments>

      <u:CalendarAppointment startDate="{StartDate}" endDate="{FinishDate}">

      </u:CalendarAppointment>

      </appointments>

      </PlanningCalendarRow>

      </rows>

      </PlanningCalendar>

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.