I have been using w2ui grid for displaying information in a table. It has worked great, but I did not particularly like how the table looks. So I was looking to style it. Is there a way to style the table without directly editing the css for w2ui?
As mentionned by TheUknown, I believe that it is more convenient to simply write As mentionned by TheUknown, I believe that it is more convenient to simply write your css rules.
But you can also use the 'style' common property on many elements such as your grid, columns or records.
See this example :
jsfiddle link
$('#myGrid').w2grid({
name : 'myGrid',
columns: [
{ field: 'fname', caption: 'First Name', size: '30%', style : 'border: 1px solid blue' },
{ field: 'lname', caption: 'Last Name', size: '30%', style : 'font-weight: bold' },
{ field: 'email', caption: 'Email', size: '40%' },
{ field: 'sdate', caption: 'Start Date', size: '120px' },
],
records: [
{ recid: 1, fname: 'John', lname: 'Doe', email: 'jdoe#gmail.com', sdate: '4/3/2012', style : 'border: 1px solid green' },
{ recid: 2, fname: 'Stuart', lname: 'Motzart', email: 'jdoe#gmail.com', sdate: '4/3/2012' },
{ recid: 3, fname: 'Jin', lname: 'Franson', email: 'jdoe#gmail.com', sdate: '4/3/2012' }
],
style : 'border: 1px solid red'
});
You can add class onRender event or onRefresh event. This apply for w2ui widgets: layout, grid, toolbar, sidebar, tabs, form.
$('#myGrid').w2grid({
name : 'myGrid',
columns: [
{ ... },
],
records: [
{ ... }
],
onRender: function(event) {
event.onComplete = function() {
$('[name="myGrid"]').addClass('grid-custom');
}
},
});
This is an old question, but still somewhat relevant since this library is still being used by a lot of people.
My solution to this was to create a separate stylesheet called "w2ui-overrides.css" and then override the classes that are defined in the supplied w2ui stylesheet.
For instance, the default border style for the sidebar context menu is
.w2ui-overlay > div {
border-radius: 4px;
position: relative;
border: 3px solid #777777;
}
But I didn't care for that, so I added this to my overrides css:
.w2ui-overlay > div {
border-radius: 2px;
border: 1px solid #777;
}
And so on, for all of the styles I wanted to change. I use the Chrome developer tools to find the class names and selectors that I need to override.
Related
I am using react grid and I would like to set the hover color and rowSelectedColor for each row differently, When I tried overwriting the hover background color it applies to every row not each row.
example - https://plnkr.co/edit/UwszBQxteLy9vPE3
I tried using rowClassRule for achieving the functionality but it did not worked, I am expecting row should have there own unique hover color and selected background color based on some condition ex: age>10 then hover-color: Red
Your code seems working to me, you just didn't passed the correct classname to your other rules.
Here's the code edited, with one new class
// main.js
const gridOptions = {
rowData: getData(),
columnDefs: [
{ headerName: 'Employee', field: 'employee' },
{ headerName: 'Number Sick Days', field: 'sickDays', editable: true },
],
rowClassRules: {
// row style function
'warning': (params) => {
var numSickDays = params.data.sickDays;
return numSickDays > 1 && numSickDays <= 5;
},
// row style expression
'breach': 'data.sickDays >= 5',
'new': 'data.sickDays >= 7'
},
};
For the style you don't need to put !important to override, try to understand why the style you want does not apply before using !important
// styles.css
.warning {
background-color: sandybrown;
}
.warning:hover {
background-color: purple;
}
// you set the class to 'blue' but the class did not exists in your style, so I set it to 'breach' because that's a class you had
.breach {
background-color: lightcoral;
}
.breach:hover {
background-color: black;
color: white;
}
.new {
background-color: greenyellow;
}
The edited and working sandbox : https://plnkr.co/edit/CijuUinXkVUJkRFG
Creating an EXT js file:
Add border to header and body of tabpanel.
I have tried adding below stuff in .scss file, but did not work.
*.scss
.maintabpanel1 {
.x-tab-bar-plain { border:1px solid red !important;
}
.x-tab-bar-top+.x-panel-body, .x-panel.x-tabpanel-child {
border: 1px solid green !important;`enter code here`
}
You need to provide cls and bodyCls to your tabpanel.
An cls optional extra CSS class that will be added to this component's Element. The value can be a string, a list of strings separated by spaces, or an array of strings. This can be useful for adding customized styles to the component or any of its children using standard CSS rules.
A bodyCls class, space-delimited string of classes, or array of classes to be applied to the panel's body element.
In this gitlab-repo, I have created a demo using ExtJS6.2. I hope this will help/guide you to achieve your requirements.
screenshot from my local.
CODE SNIPPET
Ext.define('GeoLocation.view.main.Main', {
extend: 'Ext.tab.Panel',
xtype: 'app-main',
cls: 'x-geo-tab',
bodyCls: 'x-geo-tab-body',
controller: 'main',
titleRotation: 0,
tabRotation: 0,
activeTab: 0,
items: [{
title: 'Tab 1',
html: 'it is tab 1'
}, {
title: 'Tab 2',
html: 'it is tab 2'
}, {
title: 'Tab 3',
html: 'it is tab 3'
}]
});
CSS part
.x-geo-tab {
.x-tab-bar-default {
background-color: #ece2e2;
border: 2px solid red !important;
padding: 5px;
.x-tab-bar-strip-default {
background-color: red;
height: 2px !important;
}
}
.x-geo-tab-body {
border: 2px solid green !important;
padding: 10px;
}
}
I am using Sencha Touch 2.2.1 . I want to display list items with icons, for that I am using itemTpl config property of the list. The image is rendered as icon but the list item is not getting aligned properly- it appears starting from much below. I want the text to get started from the top- it must be aligned horizontally with the image. I also tried changing 'margin' property but it didn't seem to work.
Please find my code below:
Ext.define('BBraunSencha.view.ListPanel',{
extend: 'Ext.Panel',
xtype: 'listpanel',
config:{
layout:{
type: 'vbox',
align: 'stretch'
},
items:[
{
xtype: 'label',
html: '<div style="margin-left: 20px;">List one</div>'
},{
xtype: 'list',
flex: 1,
ui:'round',
scrollable: true,
data:[
{ name: 'item1', price:'2000',in_stock : 'no'},
{ name: 'item2', price: '3000',in_stock :'yes'}
],
itemTpl: '<img src="images/Tulips.jpg" style="height: 50px;width: 50px;display:inline-block;margin-right:50px;"/>{name}'
}
]
} });
What can be the other way to achieve it?
Add a class to your css, then use that class for your itemTpl:
CSS file:
.tulip-icon {
background-image: url(images/Tulips.jpg);
background-size: 50px 50px;
background-repeat: no-repeat;
padding-left: 50px;
}
JS Code:
itemTpl: '<div class="tulip-icon">{name}</div>'
Add css:
.list-image{
height:20px;
width:20px;
float: left;
}
in js file:
itemTpl:'<div><img src="images/Tulips.jpg" class="list-image">{name}</div>'
I'm trying to format each record I retrieve from a server by using a class (carousel-squares) defined in a css file. I need that each record appears inside a thumbnail in my view.
However, when I use it inside a div in my itemTpl, nothing appears. Why itemTpl does not recognize the class? If i use the class outside (in cls:) it is recognized.
The code I have in my dataview is the following:
xtype: 'dataview',
store: {
autoLoad: true,
fields: ['Title', 'Description', 'State'],
proxy: {
type: 'ajax',
url: 'ws/idea/GetByState.php?title=&page=1',
reader: {
type: 'xml',
record: 'WebIdea',
rootProperty: 'GetByStateResult'
}
}
},
styleHtmlContent: true,
cls: 'carousel-squares',
itemTpl: '<div class="carousel-squares"><h3>{Title}</h3><p>{Description}</p></div>',
flex: 1
My css is the following:
.carousel-squares {
background-color: #fcfcfc;
border: 2px solid #99cb39;
width: 90%;
height: 30px;
margin: 20px 5px;
}
How can I customize a Sencha Touch picker completely?
Here is what the default picker looks like.
I've managed to customize the frame, center, and buttons but I can't find anything to allow me to customize that blue gradient toolbar. I can't even find a place to make it transparent.
My Picker with the code below
Code:
Ext.define('FOLUI.view.pageValuePicker', {
extend: 'Ext.picker.Picker',
alias: 'widget.pageValuePicker',
config: {
cls: 'PickerFrame',
height: 200,
itemId: 'pageValuePicker',
doneButton: {
cls: 'PaginationButton',
width: '80px',
pressedCls: 'PaginationButtonPressed'
},
cancelButton: {
cls: 'PaginationButton',
width: '80px',
pressedCls: 'PaginationButtonPressed'
},
slots: [
{
xtype: 'pickerslot',
cls: [
'PickerMiddle'
],
itemId: 'pageValuePickerSlot',
align: 'center',
data: [
{
text: '1',
value: 1
},
{
text: '2',
value: 2
},
{
text: '3',
value: 3
},
{
text: '4',
value: 4
},
{
text: '5',
value: 5
},
{
text: '6',
value: 6
},
{
text: '7',
value: 7
},
{
text: '8',
value: 8
},
{
text: '9',
value: 9
}
],
name: 'pageValuePickerSlot'
}
]
}
});
CSS:
.PaginationButton {
background: #002c42 !important;
color:#ffffff;
font-size: 16px;
font-weight: bold;
border-radius: 4px;
border: 1px solid #000d13;
-webkit-box-shadow: inset 0px 1px 0px #678796;
}
.PaginationButtonPressed {
background: #00344e !important;
color:#ffffff;
font-size: 16px;
font-weight: bold;
border-radius: 4px;
border: 1px solid #000d13;
-webkit-box-shadow: inset 0px 1px 0px #678796;
}
.PickerFrame {
background: #dae4ec !important;
border: 1px solid #6890b0;
-webkit-box-shadow: inset 0px 1px 0px #ffffff;
}
.PickerMiddle {
font-family: Arial, "Helvetica Neue", Helvetica, sans-serif;
color: #022c42 !important;
font-weight: bold;
line-height: 45px;
background-color: #ffffff !important;
border-radius: 6px;
border-top-left-radius: 0px;
border-top-right-radius: 0px;
border: 1px solid #6890b0;
-webkit-box-shadow: inset 0px 0px 13px 3px #cbcbcb;
}
You can style ST against the default element classes it uses. Easiest is to "Inspect Element" in your browser and check what class the relevant item has (ST class names start with x-, like x-toolbar). If you want to prevent styling any items which aren't part of your modified widget, you can give your widget a unique id/class and prefix your CSS rules with that.
If you feel awkward overriding its existing styling from your own CSS file, or if you want to dig deeper into styling/theming ST: ST uses SASS/Compass to build CSS files. It's a bit of a pain to set up, but the upside is that you can use SASS/Compass functions to create your own gradients, color-schemes, and such. Plus the result is that you end up with only one CSS file containing everything.
The picker has pseudo class with gradient. But chrome's dom inspector has some strange behaviour and may not displays pseudo classes. So you can't find it. Go to the CSS file and edit styles there.
You can really extend the options you wish to configure by using this trick:
items: [
{
xtype: 'selectfield',
label: 'Choose one',
usePicker: 1, // convert selectfield into a picker
defaultPhonePickerConfig: { // customise text values displayed
doneButton: 'Select',
cancelButton: 'Cancel'
},
options: [
{text: 'First Option', value: 'first'},
{text: 'Second Option', value: 'second'},
{text: 'Third Option', value: 'third'}
]
}
]
Now as to the styling which you wish to avoid, simply do not include it. You are seeing the ST default styling being called in. You've managed to override part of the styling, and by showing you this example above where a select can be a picker, you can see just how varied a location where styling may be called in.
Primary culprit (ST2.2):
#import 'sencha-touch/default';
#import 'sencha-touch/default/all';
Comment out the "all" line, then call in only the individual components you wish to be default styled.
// #import 'sencha-touch/default/all';
// replacing direct reference to exact path of component mixin
// all in relation to the "sencha-touch" folder which is pathed in config.rb
#import 'sencha-touch/default/src/_MessageBox.scss';
#import 'sencha-touch/default/src/_Toolbar.scss';
Once you get used to the structure of the mixin files and how it is all referenced and called, you can simplify your life by only calling in the absolute minimum structure from ST, namely the "base". Take a copy of the mixin components for what you wish to use into /resources/sass/mixins, modify the styling to suit your needs. The result is a far smaller stylesheet generated, cutting out all the hair-tearing overriding of defaults.