mat-table can't bind dataSource - material-design

I am trying to use angular material table MatTableModule, but when passing the data to the [dataSource] input I am getting the Can't bind to 'dataSource' since it isn't a known property of 'table'. error. I have already imported the MatTableModule and as pointed at GitHub issue #5577 also imported CdkTableModule but still no luck. Any ideas?

The problem was that the material angular version I'm using is v5.2.4, so the template should be <mat-table #table [dataSource]="dataSource"></mat-table> instead of <table mat-table #table [dataSource]="dataSource"></table> according to Angular material v5.2.4 documentation.
https://v5.material.angular.io/components/table/overview#1-write-your-mat-table-and-provide-data

Related

Tabulator Invalid column definition option

I have recently upgraded from Tabulator 4.9 to Tabulator 5.1.7.
Previously, I was adding some user-defined attributes into the column definitions.
The was done so that column headerContextMenu functions had ready access to info.
This all worked fine and we observed the expected warnings in the browser console.
With the new version, the presence of user-defined attributes in column definitions causes issues with headerContextMenu functions.
Uncaught TypeError: Cannot read properties of undefined (reading 'headerContextMenu')
The above error only occurs when there is a user-defined attribute in the column definition. I am seeing this on multiple tables in our application.
Are user-defined attributes in column definitions no longer allowed?
Because Tabulator now uses optional module, not all column definition options always exist, it therefore warns you if it detects you are using an option that is not being watched by a module, just incase you have forgotten to install that module.
You can disable this functionality by setting the debugInvalidOptions option to false
var table = new Tabulator("#example-table", {
debugInvalidOptions:false,
});
Full details can be found in the Debug Documentation

Jest - how to test if a component does not exist?

How do I check if a component is not present, i.e. that a specific component has not been rendered?
.contains receives a React Node or array of Nodes as an argument. Instead, use .find:
expect(wrapper.find('selector').exists()).toBeTruthy()
You can use enzymes contains to check if the component was rendered:
expect(component.contains(<ComponentName />)).toBe(false)
If you're using react-testing-library (I know the OP wasn't but I found this question via web search) then this will work:
expect(component.queryByText("Text I care about")).not.toBeInTheDocument();
You can query by Text, Role, and several others. See docs for more info.
Note: queryBy* will return null if it is not found. If you use getBy* then it will error out for elements not found.
Providing a slightly updated answer based on the documentation for enzyme-matchers's toExist. This will require you to install the enzyme-matchers package.
function Fixture() {
return (
<div>
<span className="foo" />
<span className="bar baz" />
</div>
);
}
const wrapper = mount(<Fixture />); // mount/render/shallow when applicable
expect(wrapper.find('span')).toExist();
expect(wrapper.find('ul')).not.toExist();
.contains does not expect a selector, unlike find. You can look at the length attribute of the ShallowWrapper
expect(wrapper.find('...')).toHaveLength(0)
I found I needed to use this syntax with Enzyme and Jest to test if a Connected Component existed in the rendered output.
We use Jest and Enzyme, and I've found the only good test is to import the sub-component and test this way:
expect(component.find(SubComponent).length).toEqual(0); // or (1) for exists, obvs
I tried all the other answers and none worked reliably.
If you are using react-testing-library, then this also will work:
expect(component.queryByText("Text I care about").toBeNull());
expect(within(component).queryByText("Text I care about")).toBeNull();
Note: In my case, I needed to use queryBy* because it doesn´t error out when the text element (that contains the text: Text I care about) does not exist. Therefore, I could evaluate whether there is an existence of a text component or not.

How to use mdl-select and md-option

I've been using angular2-mdl for a while and it's brilliant, now I want to also use #angular2-mdl-ext on a project using systemjs but am having trouble and get errors indicating mdl-select and mdl-option is not known in component. I did an import of MdlSelectModule on the component but it does not help.
How should I specify this in app.module.ts and and systemjs.config.js, all attempts at getting it to resolve have failed thus far.
I tried import MdlSelectModule in app.module.ts but keep etting a 404 error which tells me systemjs is not configured properly....?
An example indicatig how to specify in systemjs.config.js and app.module.ts would be appreciated.
Thanks,
Resolved this by setting mapping in systemjs as follows
'#angular2-mdl-ext/select': 'npm:#angular2-mdl-ext/select/index.umd.js',

asp.net mvc5 scaffolding Unable to retrive metadata for ...Ambiguous match found

Problem: When I want to create controller from EF codefirst context it give me this error:
There was an error running the selected code generator.Unable to retrieve metadata for Model.class name.Ambiguous match found.
See Error Image
What I did?
As my model data was in seprate assembly I updated all package or downgrade them but nothing happened.
Then I merged my Model assembly in Website project but error doesn't resolved.
After googleing and many tricks, I created clean project and scaffolding for each class but it seems only one class had this problem.
In that class I commented all property and uncomment one by one to find error.
Found it! For this property error occurs public bool ISActive { get; set; }
I surprised so much and found how dot net turture you!!
What do you think about solution?!!
Renaming ISActive property to something else such as IsActivated solved my problem.It seems EF scaffolding has problem with this type of naming while cruding.

Kohana 3.3 ORM - Database Views

Is there a way to use the orm factory to pull from a view instead of a table? I was hoping that the syntax would be equivalent to pulling from a table:
$buyers = ORM::factory('vbuyer'); //where vbuyers is the name of the view
This results in the error : ErrorException [ Fatal Error ]: Class 'Model_Vbuyer' not found
Unfortunately that doesn't seem to work. Can I have the orm map a view to a model, or do I have to use the DB::select('*')->from('vbuyers') approach?
EDIT: The problem was actually that the filename of the vbuyer model was incorrect, it had an underscore v_buyer. Removed the underscore and it worked.
EDIT: To answer the original question - yes, you can use the ORM factory to generate models based on database views. The problem in this case was unrelated, see above.

Resources