- As the title says when I try to create a model using component factory it creates an error instead:
TypeError: Cannot read property ‘core’ of undefined
I am able to bypass the error if I also create a chart with Skuid Composer, but that’s a hack and not ideal.
Use case: I have a function that dynamically creates models, then it creates charts and tables for the model.
XML:
<skuid__page unsavedchangeswarning=“yes” personalizationmode=“server” showsidebar=“true” showheader=“true”>
<fields>
<field id="Name"/>
<field id="Category__r.Name"/>
</fields>
<conditions/>
<actions/>
<groupby method="simple"/>
<skuid__buttonSet uniqueid=“sk-3SG–5262”>
<groups>
<skuid__buttonGroup uniqueId="sk-3SG--5260">
<buttons>
<skuid__button label="Create Chart" uniqueId="sk-3SG--5261">
<actions>
<action type="custom" snippet="newSnippet"/>
</actions>
</skuid__button>
</buttons>
</skuid__buttonGroup>
</groups>
</skuid__buttonSet>
<skuid__wrapper uniqueid=“TestJSChartWrapper”>
<components/>
<styles>
<spacing/>
</styles>
<background/>
<renderConditions logictype="and"/>
<styleVariantConditions/>
<interactions/>
</skuid__wrapper>
<labels/>
<javascript>
strXML = `
<skuid__chart model="Activity" maintitle="{{Model.labelPlural}}" type="donut" uniqueid="sk-3SEU-6021">
<dataaxes>
<axis id="axis1"/>
</dataaxes>
<categoryaxes>
<axis id="categories" categorytype="field"/>
</categoryaxes>
<serieslist>
<series valuefield="Name" splittype="field" modelId="Activity" aggfunction="count" splitfield="Category__r.Name"/>
</serieslist>
<colors/>
<legend layout="horizontal" halign="center" valign="bottom"/>
</skuid__chart>
`;
xmlDef = skuid.utils.makeXMLDoc(strXML);
var dynamicChartComponent = skuid.$(
"#TestJSChartWrapper"
);
dynamicChartComponent.empty();
dynamicChartComponent.prepend(‘
’);test = dynamicChartComponent.find(‘#new_div’);
var myComponent = skuid.component.factory({
element: test,
xmlDefinition: xmlDef,
type: "skuid__chart",
});
xmlRenderComponent = ‘’;
xmlReady = skuid.utils.makeXMLDoc(xmlRenderComponent);
skuid.actions.runActionsNode(xmlReady);
<css/>
<actionsequences/>
<styleitem type="background" bgtype="none"/>
</skuid__page>