react-data-grid headerRenderer Sorting - sorting

How is sorting and filtering implemented when using a custom header cell in the react-data-grid?
{
key: "myColumn1",
name: "My Column Name",
headerRenderer: this.renderHeader,
sortable: true,
filterable: true
},
{
key: "myColumn2",
name: "My Other Column Name",
sortable: true,
filterable: true
}
...
renderHeader(props){
return (<extra-stuff>
{props.column.name}
</extra-stuff>)
}
I have myColumn2 sorting fine but nothing happens with the custom header: myColumn1. What do I need to do in renderHeader(){} to get sorting (and filtering, but mainly sorting) working?

Instead of trying to call a function in headerRenderer, put a component instead:
{
key: "myColumn1",
name: "My Column Name",
headerRenderer: <renderHeader value={this.renderHeader()} />,
sortable: true,
filterable: true
},

Looks like a solution was checked-in for this almost a year ago. I do work on an intranet and don't have direct internet access for development so maybe i have an older version. Since I can't get the version in my environment I'll wait for someone to verify that the latest version works as expected before I accept my own answer (or I'll try to get the latest version with the change in there.)
One other thing I will have to do with the way the solution was implemented is stop propagation of the click event because in my custom header i have a ReactIcon that is clickable to change from status wording to a menu. So, if they click right on the icon in the header do the name/menu change and if they click anywhere else in the header then do the sort. I'll have to look up how to do that in React.
Update
I took the changes from the check-in in the link above and added them to my react-data-grid.js and it works great. I.e. I had to add the changes to the pure javascript version of the code that npm pulled into our node_modules.
I also did have to use e.stopPropagation() call in my headerRenderer like i thought i'd have to so that clicking the icon i have in the headerRenderer would not sort when click (but just do a different operation) but it was easy to add.
I do have one question about the change i made to my js which here is a piece of the change...
return React.createElement(
'div',
{className: className,
onClick: this.onClick,
style: {cursor: 'pointer'} },
React.createElement(
'span',
{ className: 'pull-right' },
this.getSortByText()
),
//change was here from just: this.props.column.name
this.props.column.headerRenderer? this.props.column.headerRenderer(this.props) : this.props.column.name
);
How would i have done this in JavaScript so that it would work whether my headerRenderer was ()=>{ return <span>...</span> } or <MyComponent /> ???
Since i always use functions for my headerRenderer i just did the change so that it worked the one way but would like to know how to make the change so it works both ways. Something like this? ...
this.props.column.headerRenderer?
(isFunction(this.props.column.headerRenderer)? this.props.column.headerRenderer(this.props) : React.createElement(this.props.column.headerRenderer, {...this.props}) )
:
this.props.column.name
????

Related

How do i fix DEPRECATION: The matcher factory for "toHaveBeenTriggeredOnAndWith"?

Can anyone tell me what needs to be changed this test?
it('Should update settings of bar', () => {
const newSettings = {
dataset: [
{
data: [{
name: 'Category A',
value: 373,
color: '#1D5F8A',
id: 1
}],
name: ''
}
]
};
barObj.updated(newSettings);
const dataLength = barObj.settings.dataset[0].data.length;
expect(dataLength).toEqual(1);
});
I am getting this error from Jasmine and if i follow the link https://jasmine.github.io/tutorials/upgrading_to_Jasmine_4.0#matchers-cet i dont see exactly what i would need to change?
ERROR: 'DEPRECATION: The matcher factory for "toHaveBeenTriggeredOnAndWith" accepts custom equality testers, but this parameter will no longer be passed in a future release. See https://jasmine.github.io/tutorials/upgrading_to_Jasmine_4.0#matchers-cet for details. (in spec: Bar API Should update settings of bar)
I also cant find a lot of information about this message. I also dont have any custom equality matchers in the system. https://jasmine.github.io/tutorials/custom_equality
Try to update karma-jasmine package. It helped me.
I had this problem using "#metahub/karma-jasmine-jquery". You can modify the bundle in place and remove the second parameter from the `` toHaveBeenTriggeredOnAndWith" function. Or copy the module somewhere, uninstall "#metahub/karma-jasmine-jquery" and install the modified module: npm install ./#metahub/karma-jasmine-jquery

How do I implement a "Settings" section for a custom Teams Message Extension?

I built a small teams message extension which just uses some user input, builds a link from it, and returns a card with a button pointing to that link.
I need to add a Settings section, but I couldn't find proper instructions or a sample for this.
I tried to use this sample as example (which is JS, and I'm using TypeScript), but I could not get it to work.
Relevant portion in my class:
export class MessageExtensionBot extends TeamsActivityHandler {
...
protected handleTeamsMessagingExtensionConfigurationQuerySettingUrl(context: TurnContext, query: MessagingExtensionQuery): Promise<MessagingExtensionResponse> {
return Promise.resolve({
composeExtension: {
type: "config",
suggestedActions: {
actions: [
{
title: "Title",
type: ActionTypes.OpenUrl,
value: "https://" + `${process.env.PUBLIC_HOSTNAME}` + "/settings.html"
}
]
}
}
});
}
protected handleTeamsMessagingExtensionConfigurationSetting(context, settings): Promise<void> {
return Promise.resolve(undefined);
}
process.env.PUBLIC_HOSTNAME points to the temporary ngrok link, smth like xxx-yyy-zzz.ngrok.io.
When I access xxx-yyy-zzz.ngrok.io/settings.html, I get the correct content of that html file
I also added "canUpdateConfiguration": true, in my manifest file, and the Settings link is available.
THE PROBLEM: when I click the Settings link in my custom teams message extension, all I get is a pop-up with the error message Sorry, the setting of this compose extension is not available. Please try again later. and an OK button.
What is wrong/missing in my code ?
Thank you.
We also faced this issue. It is resolved after adding validDomains in the manifest. Please try updating the validDomains in manifest, hope this resolves the issue.

HTML Beautify Settings in Brackets

I understand that the Brackets Beautify extension is based on JS Beautify, and that I have a suite of preference settings available because of that, but I have no idea of how to alter them through the Brackets settings.json file. Does anyone have any idea?
Here are my current settings:
{
"debug.showErrorsInStatusBar": false,
"linting.collapsed": true,
"wordWrap": false,
"me.drewh.jsbeautify.on_save": false,
"styleActiveLine": true,
"themes.theme": "explicit-brackets-style",
"fonts.fontSize": "12px"
}
I'm assuming I just need to add new "me.drewh.jsbeautify" lines, but that doesn't seem to work...
I'm specifically looking at HTML settings, BTW.
Like the original library the extension uses a .jsbeautifyrc file for the settings.
It should work if you create such a file in your project root with content like this:
{
"eol": "\n",
"end_with_newline": true,
"preserve_newlines": true,
"max_preserve_newlines": 10,
"indent_inner_html": false,
"brace_style": "collapse",
"indent_scripts": "normal",
"wrap_line_length": 0,
"wrap_attributes": "auto"
}
Additionally, I can only recommend you to have a look at my fork of that extension as it allows more detailed settings.

Can't get alchemy.js graph visualisation to show panel, zoom or search

The alchemy.js lib is create and provides good abstraction for graph layouts. I can't seem to get the application example that has a panel, allows searching and filtering. Zooming does not work either.
Here are the config values:
var config = {
dataSource: team,
cluster: true,
nodeCaption: "firstName",
rootNodeRadius: 30,
nodeCaptionsOnByDefault: true,
directedEdges:true,
showControlDash: true,
showStats: true,
nodeStats: true,
showFilters: true,
nodeFilters: true,
captionToggle: true,
edgesToggle: true,
nodesToggle: true,
toggleRootNotes: false,
search: true,
zoomControls: true
};
Here is the code that is not working:
https://jsfiddle.net/aneesha/mpa6sbsb/6/
So... I dug around and they seem to have left toggleControlDash out of Alchemy.prototype.interactions in the last couple of versions. I went back to their 0.3.1 version, copy/pasted the function into the new alchemy.js file, and now it works.
I'm pretty sure the examples are all built on different versions. I've found some other things that don't work too, I'm just going to go in and fix them on my own. If you're still looking for help on this, let me know :)

Attaching multiple views to a controller in ExtJS 4 MVC

This is using the standard ExtJS 4 MVC library and structure.
I am trying to attach multiple views to a single controller so I can create instances of them later to add to panels. Unfortunately I am getting errors about the view when I add the second one and ExtJS is blocking the syntax errors it appears so that I am unable to see where the issue is.
If I comment out ViewOrders from the list below it works fine, but if it is in there then I get the following error:
An uncaught error was raised with the following data: ext-all-debug-with-comments.js (line 7864)
msg:
"The following classes are not declared even if their files have been loaded: 'PVAL_App.view.ViewOrders'. Please check the source code of their corresponding files for possible typos: 'app/view/ViewOrders.js'"
sourceClass: "Ext.Loader"
sourceMethod: "onFileLoaded"
Here is my controller:
Ext.define('PVAL_App.controller.Viewport', {
extend: 'Ext.app.Controller',
views: [
'Viewport', 'ViewOrders'
],
init: function() {
console.log('Viewport controller init()');
}
});
Here is my ViewOrders view:
Ext.define('PVAL_APP.view.ViewOrder', {
/* Begin Definitions */
extend: 'Ext.panel.Panel',
alias: 'widget.ViewOrders',
requires: [
'Ext.panel.Panel',
'Ext.data.ArrayStore'
],
border:false,
layout: 'fit',
//autoScroll: true,
initComponent: function() {
}
});
I doubt this is needed but this is my application file:
Ext.Loader.setConfig(
{
enabled: true
});
Ext.application({
name: 'PVAL_App',
appFolder: 'app',
autoCreateViewport: true,
controllers: [
'PVAL_App', 'Viewport'
],
launch:function() {
// Nothing yet.
//console.log(this.controllers);
}
});
I cannot seem to figure out if it is a syntax error or if this is an issue with the framework. I have experienced close to the same issue if I try to link to another controller from within one which makes me believe that this might be a constraint of the framework.
The problem here is that the class name in your app/view/ViewOrders.js script does not match the view name. Instead of Ext.define('PVAL_APP.view.ViewOrder', { you need the plural (and correct case) Ext.define('PVAL_App.view.ViewOrders', {. Either that our you can change your filename and refernece to the singular and just correct the case.

Resources