YUI3 Datatable : How to apply separate css class for Table headers and Table data - yui3

I am trying to apply different css classes to the datatable header and the datatable data. But the className attribute in the columns field of the yui3 datatable only applies it to the data. I tried the headerTemplate attribute but it doesn't display the column label. Here is my code in jsfiddle http://jsfiddle.net/anandp504/hJsMk/1/ and the javascript code for the datatable. The column with key "day" is where I am trying to apply a css class for the column header
YUI().use("datatable", "datatype", function (Y) {
/*------------------------------------*/
function formatDate(cell) {
return Y.DataType.Date.format(cell.value, { format: cell.record.get('date_format') });
}
/*------------------------------------*/
function formatCurrency(cell) {
//console.log("column key : " + cell.column.key);
if(cell.column.key == "imps"){
console.log(JSON.stringify(cell));
}
format = {
prefix: "$",
thousandsSeparator: ",",
decimalSeparator: ".",
decimalPlaces: 2
};
cell.record.set(Number(cell.value));
return Y.DataType.Number.format(Number(cell.value), format);
}
/*------------------------------------*/
/*-- create datatable --*/
var datatable = new Y.DataTable({
columns: [
{key: "day", label: "Day", headerTemplate: '<th id="{id}" title="Day" class="datatable-header" {_id}>●</th>', formatter: formatDate, sortable: true, allowHTML: true},
{key: "campaign",label: " Campaign Name", sortable: true},
{key: "imps",label: " Impressions", formatter: formatCurrency, sortable: true, className: "number"},
{key: "clicks",label: "clicks", className: "number", sortable: true},
{key: "totalConvs",label: "Total Conversions", className: "number", sortable: true},
{key: "costEcpm",label: "Cost Ecpm", formatter: formatCurrency, sortable: true, className: "number"},
{key: "revenueEcpm",label: "Revenue Ecpm", formatter: formatCurrency, className: "number", sortable: true},
{key: "profitEcpm",label: "Profit Ecpm", formatter: formatCurrency, className: "number", sortable: true}
],
/*-- Data Set for the DataTable --*/
data : [
{"day": Y.DataType.Date.parse("Sun Aug 15 00:00:00 GMT+05:30 2013"), "date_format": "%d-%b-%Y", "campaign": "**Academy Bus 2013 Charter Geo ron DC FBX rt 1x1 cm.fbx/academydc (1601412)","imps": "24393","clicks": Number("3"),"totalConvs": Number("0"),"costEcpm": Number("0.191327675972615094494000"),"revenueEcpm": Number("3.950000000000000000000000"),"profitEcpm": Number("3.758672324027384905506000") },
{"day": new Date("Sun Aug 02 00:00:00 GMT+05:30 2013"), "date_format": "%d-%b-%Y", "campaign": "**Academy Bus 2013 Charter Geo ron Boston rt FBX 1x1 cm.fbx/academybos (1601410)","imps": "22067","clicks": Number("6"), "totalConvs": Number("0"),"costEcpm": Number("0.186746318031449675987000"),"revenueEcpm": Number("3.950000000000000000000000"),"profitEcpm": Number("3.763253681968550324013000") },
{"day": new Date("Sun Aug 09 00:00:00 GMT+05:30 2013"), "date_format": "%d-%b-%Y", "campaign": "**Academy Bus 2013 Charter Geo DC BOOM 300 App_cm.AcademyBus_WashingtonDC (1505444)","imps": "10157","clicks": Number("0"),"totalConvs": Number("0"),"costEcpm": Number("1.133644899187481191694000"),"revenueEcpm": Number("1.909000000000000000000000"),"profitEcpm": Number("0.775355100812518808306000") },
{"day": new Date("Sat Aug 06 00:00:00 GMT+05:30 2013"), "date_format": "%d-%b-%Y", "campaign": "**Academy Bus 2013 Charter Geo ron Boston rt FBX 1x1 cm.fbx/academybos (1601410)","imps": "1048","clicks": Number("5"),"totalConvs": Number("0"),"costEcpm": Number("0.193939241407362212731000"),"revenueEcpm": Number("3.950000000000000000000000"),"profitEcpm": Number("3.756060758592637787269000") }
],
summary: "Price sheet for inventory parts",
caption: "Network Advertiser Analytics"
});
datatable.render("#datatable-example");
});

The assumption is that you would use the th or td selector along the className in your CSS style definition so you can tell them apart. In your case, th.yui3-datatable-col-day for the header cell and td.yui3-datatable-col-day for the data cells. Likewise, you could use thead .yui3-datatable-col-day.
In recent versions, the formatters you use are built into datatable. You just need to add the datatable-formatters module to your dependencies. See the API Docs.

I had to create css classes as below and assign them under className attribute for columns:
.yui3-datatable th.datatable-header {
text-align: center; font-weight:bold ; color: #00000; font-family: Arial, Helvetica, sans-serif; font-size: 12px;
}
.yui3-datatable td.datatable-data {
color: #00000; font-family: Arial, Helvetica, sans-serif; font-size: 10px;
}
The column attribute will look like below:
columns: [
{key: "day", label: "Day", formatter: formatDate, sortable: true, allowHTML: true, className: "datatable-header datatable-data"},
{key: "campaign",label: " Campaign Name", sortable: true, className: "datatable-header datatable-data"},
{key: "imps",label: " Impressions", formatter: formatCurrency, sortable: true, className: "datatable-header datatable-data number"},
{key: "clicks",label: "clicks", className: "number", sortable: true, className: "datatable-header datatable-data number"}
]

Related

angular ag grid not working with angular 5

I want to use ag-grid in my angular 5 application
but I am unable to use as it throws an exception in my console.
My component code:
columnDefs = [
{headerName: "First Name", field: "first_name", width: 100, editable: true},
{headerName: "Last Name", field: "last_name", width: 100, editable: true},
{
headerName: "Gender",
field: "gender",
width: 90,
cellEditor: 'mySimpleCellEditor'
},
{
headerName: "Age",
field: "age",
width: 70,
cellEditor: 'mySimpleCellEditor'
},
{
headerName: "Mood",
field: "mood",
width: 70,
cellEditor: 'mySimpleCellEditor'
},
{
headerName: "Country",
field: "country",
width: 100,
cellEditor: 'mySimpleCellEditor'
},
{
headerName: "Address",
field: "address",
width: 502,
cellEditor: 'mySimpleCellEditor'
}
];
rowData = [
{
first_name: 'Bob', last_name: 'Harrison', gender: 'Male',
address: '1197 Thunder Wagon Common, Cataract, RI, 02987-1016, US, (401)
747-0763',
mood: "Happy", country: 'Ireland'
},
];
My html code:
<div>
<ag-grid-angular #aggrid style="width: 100%; height: 350px;"
class="ag-theme-balham"
[columndefs]="columnDefs"
[showtoolpanel]="true"
[rowdata]="rowData"
enablecolresize
enablesorting
enablefilter
rowheight="22"
rowselection="multiple">
</ag-grid-angular>
</div>
My app.module.ts code:
import { AgGridModule } from "ag-grid-angular/main";
imports: [
AgGridModule.withComponents([])
],
I am still getting the below error in my console and I am unable to run my application.
(anonymous) # bootstrap.min.js:6
compiler.js:215 Uncaught Error: Template parse errors:
Can't bind to 'columndefs' since it isn't a known property of 'ag-grid-
angular'.
1. If 'ag-grid-angular' is an Angular component and it has 'columndefs'
input, then verify that it is part of this module.
2. If 'ag-grid-angular' is a Web Component then add
'CUSTOM_ELEMENTS_SCHEMA' to the '#NgModule.schemas' of this component to
suppress this message.
3. To allow any property add 'NO_ERRORS_SCHEMA' to the '#NgModule.schemas'
of this component. ("id-angular #aggrid style="width: 100%; height: 350px;"
class="ag-theme-balham"
[ERROR ->][columndefs]="columnDefs"
[showtoolpanel]="true"
[rowdata]="): ng:///AppModule/GridtestComponent.html#3:21
Can't bind to 'showtoolpanel' since it isn't a known property of 'ag-
grid-angular'.
1. If 'ag-grid-angular' is an Angular component and it has 'showtoolpanel'
input, then verify that it is part of this module.
I tried almost everything but still not able to resolve this issue.
How about instead of using...
[columndefs]="columnDefs"
[rowdata]="rowData"
You use...
[columnDefs]="columnDefs"
[rowData]="rowData"
Also, basically nothing - except address - in your rowdata matches the field names of your headers. AgGrid won't render data when it has no matching header for those. Please don't try to simply insert code at random. The main page has an easily accessible Get Started page.
You need import in app.module this:
import { NgModule, CUSTOM_ELEMENTS_SCHEMA, NO_ERRORS_SCHEMA } from '#angular/core';
#NgModule({
schemas: [
CUSTOM_ELEMENTS_SCHEMA,
NO_ERRORS_SCHEMA
],
...

Background image link by data array

I get this error in cytoscape.js:
"Do not assign mappings to elements without corresponding data (e.g. ele p for property background-image with data field linkImagem); try a [linkImagem] selector to limit scope to elements with linkImagem defined"
Look data array:
{ data: { id: 'atr1', classificacao : '1', backgroundColor : '#F79646', nomeAtributo : 'Bancos desconfortáveis', angulo : '0', valign : 'top', halign : 'right', linkImagem : 'http://www.fec.unicamp.br/~confterm/imagens/background/nodes/8.png' }, position: { x:220, y: 300 }, selected: false, selectable: false, locked: false, grabbable: false }
Look script style options:
.selector('node')
.css({
'label': 'data(nomeAtributo)',
'text-valign': 'data(valign)',
'text-halign': 'data(halign)',
'color' : '#000',
'font-size': '11px',
'background-fit': 'fit',
'background-color': 'data(backgroundColor)',
'background-image': 'data(linkImagem)',
})
How I can solve this?
The solution is given to you in the error message. Either don't use mappers if you're not going to define the data for each matching element, or adjust your selectors so that they only match elements with the data defined.

Add an input element of type=file in tinymce container

I am trying to extend a tinymce pluggin and need to add an input element of type=file.
(I am new to such an exercise so please pardon my ignorance.. Also could not find examples/samples to work with..)
It seems you can do the following to show elements to a container that opens in a panel :
var generalFormItems = [
{name: 'alt', type: 'textbox', label: 'Image description'},
{name: 'width', type: 'textbox', maxLength: 3, size: 3, onchange: recalcSize},
];
win = editor.windowManager.open({
title: 'Insert/edit image',
data: data,
bodyType: 'tabpanel',
body: [
{
title: 'General',
type: 'form',
items: generalFormItems
},
],
onSubmit: onSubmitForm });
I am interested in adding an input html of type=file (<input type="file".../>). So there should be the usual html button that will show the 'file dialog' on the browser to allow the user to pick a file. So something like this I am hoping :
var generalFormItems = [
{name: 'alt', type: 'textbox', label: 'Image description'},
{name: 'width', type: 'textbox', maxLength: 3, size: 3, onchange: recalcSize},
---> {name: 'fileSelect', type: 'file', label: 'Select a File to Upload'},
];
Is it possible to do this and how?
Managed to figure this out and want to leave the answer here for others trying to do something similar.
There is a 'subtype' on each of the UI form elements that will get added to the DOM as is. So doing the below did the trick for me :
{name: 'file', type: 'textbox', subtype: 'file', label: 'Upload', onchange: uploadFile},
In TinyMCE 3.x all dialogs where HTML pages that got loaded into a iframe or window. This was changed in TinyMCE 4 to make it easier to make plugins and fully support CDN:s. But you can still load HTML based pages into TinyMCE dialogs by using the WindowManager.
// Opens a HTML page inside a TinyMCE dialog
editor.windowManager.open({
title: 'Insert/edit image',
url: 'dialogTemplate.html',
width: 700,
height: 600
});
Also you can inline HTML:
// Opens a HTML page inside a TinyMCE dialog
editor.windowManager.open({
title: 'Upload a file to attach',
html: '<input type="file" class="input" name="file" id="file_attach" style="font-size: 14px; padding: 30px;" />',
width: 450,
height: 80,
buttons: [{
text: 'Attach',
subtype: 'primary',
onclick: function() {
// TODO: handle primary btn click
(this).parent().parent().close();
}
},
{
text: 'Close',
onclick: function() {
(this).parent().parent().close();
}
}]
});

id for buttons in datagrid

I have the following code for adding buttons in ever row of a DataGrid:
structure: [
{field: 'msConstId', width: '0%', name: 'Milestone',hidden: true},
{field: 'edit', width: '8%', name: 'Edit',formatter: function(data, rowIndex) {
return new dijit.form.Button({style: "width: 80px;",label:"Edit", iconClass:"dijitIconEditTask",showLabel:true, onClick:function(){ updateMilestone.show(); populateUpdateControls(); }});
}},
{field: 'delete', width: '10%', name: 'Delete',formatter: function(data, rowIndex) {
return new dijit.form.Button({style: "width: 80px;",label:"Delete", iconClass:"dijitIconDelete",showLabel:true, onClick:function(){ deleteMilestoneDialog(); }});
}}
]
The problem is that I want to assign an id to each of the button as "editBtnRowIndex" and "deleteBtnRowIndex". I want to use the id's for enabling and disabling buttons in specific grid rows.
Is that possible?
I had to go with a work around for this by looking at the data in other fields and disabling the button for that row with something like this:
var rowdata = grid.getItem(rowIndex);
rowIndex is passed as param to formatter function.
var val = rowdata.myRowID;
if(val=='specific value') {
//return disabled button
} else {
//return enabled button
}

How to change the font size and color of list items in sencha touch

I have an sample application where i am binding the store data to the list using itemtpl, I have little confusion on how to change the color and size of first two list items when i am dynamically binding data to list from store.
This my sample code :
Ext.define('Sample.view.SearchResultView', {
extend: 'Ext.Panel',
requires: [
'Ext.List',
'Ext.form.FieldSet',
'Ext.field.Text',
'Ext.Toolbar',
'Ext.TitleBar'
],
alias: "widget.searchresultpage",
config: {
scrollable: true,
items: [
{
xtype: 'list',
layout:'fit',
height:500,
title: 'Search Results',
store: 'MySearchStore',
itemTpl: '<table><td><tr height=10%>{BlockNo}</tr><tr height=90%><p>{ShortDescription}</p></tr></td></table>'
)
}
]
},
});
You need to add a cls attributes to your list like :
cls:'myList'
and then add this in your CSS File :
.myList .x-list-item:nth-child(1),
.myList .x-list-item:nth-child(2) {
color: #CCC;
font-size:14px;
}
Hope this helps
you can set font and color in itemTpl itself.
itemTpl: '<table><td><tr height=10%><font size="12" color="#990000">{BlockNo}</font></tr>
<tr height=90%><p><font size="8" color="#990000">{ShortDescription}</font></p></tr></td>
</table>'