How to stop Telerik CSS from overriding local changes? - grid

I have a Kendo Grid and it the default CSS background-color or 'text' Color are what always display.
I was able to override the background colors with lines 1 & 2, however, it just replaced the colors. What I need to to be able to set the color based on the "InTruck" Boolean field.
I tried lines 5 and 6, and the html mark up is correctly updated and sometimes I see it flash the correct color before it is reset to the defaults. I have also tried adding in !important in rows 3 and 5, still no luck. Something seems to be setting the style AFTER everything is done using the kendo/telerik css. How do I stop that?
<style>
1 /*.k-grid-content>table>tbody>tr{background-color:lightgreen;}*/
2 /*.k-grid-content>table>tbody>.k-alt{background-color:red;}*/
3 .IN{color:lightgreen;}
</style>
<div id="divSearchResults">
#(Html.Kendo().Grid((IEnumerable<Models.SearchResult>)Model.SearchResults)
4 // .Events(ev => ev.DataBound("Grid_onRowDataBound"))
5 // .RowAction(row => { if (row.DataItem.InTruck) row.HtmlAttributes["style"] = "background-color:lightgreen"; else row.HtmlAttributes["style"] = "background-color:red !important"; })
.Name("grid")
6 .RowAction(row =>
{
if (row.DataItem.InTruck)
{
row.HtmlAttributes["class"] = "IN";
}
})
.DataSource(ds => ds.Ajax()
.PageSize(Constants.MaxSearchReults)
.Model(mod =>
{
mod.Id(m => m.ID);
mod.Field(p => p.Name).Editable(false);
mod.Field(p => p.CarrierCode).Editable(false);
mod.Field(p => p.CityState).Editable(false);
mod.Field(p => p.Phone).Editable(false);
}))
.Columns(columns =>
{
columns.Template(#<text></text>).ClientTemplate("<input type='checkbox' #= IsSelected ? checked='checked':'' # class='chkbx' value='#= CarrierID#' name='SelectedArea' />")
.HeaderTemplate("<input type='checkbox' id='masterCheckBox' onclick='checkAll(this)'/>").Width(20);
columns.Bound(p => p.Name).Filterable(false).Width(100);
columns.Bound(p => p.CarrierCode).Filterable(false).Width(75);
columns.Bound(p => p.CityState).Filterable(false).Width(100);
columns.Bound(p => p.Phone).Filterable(false).Width(75);
})
.Editable(ed => ed.Mode(GridEditMode.InCell))
.Pageable()
.Sortable()
.Scrollable()
.Filterable()
)
</div>

I never did figure out how to do exactly what I wanted, however, this solution has the same results and I think it looks better and easier on the eyes than what was asked for. It will set the color behind the checkbox so there is an obvious color difference but it isn't gaudy.
.Columns(columns =>
{
columns.Template(#<text></text>)
.ClientTemplate("<span style='float:left; width:100%; background:#= InTruckMate ? \"lightgreen\" : \"palevioletred\"#'><input type='checkbox' #= IsSelected ? checked='checked':'' # class='chkbx' value='#= CarrierID#' name='SelectedArea' /></span>")
.HeaderTemplate("<input type='checkbox' id='masterCheckBox' onclick='checkAll(this)'/>")
.Width(25);
columns.Bound(p => p.Name).Filterable(false).Width(100);

Related

Text formating with CSS

I am using the ant-design library with the Table and Tooltip component
I am trying to format the tooltip so that each element inside of my array is on it's own line instead of 1 big paragraph like how it is here.
The code that generates the above UI looks like this
const generateTableColumns = () => {
if (survey) {
const selectedSurvey = `${survey}`.toLowerCase()
const columnHeaders = SurveyArray[selectedSurvey].questions.map(item => ({
title: item.id,
dataIndex: item.id,
key: item.id,
ellipsis: {
showTitle: false,
},
render: dataIndex => (
<Tooltip placement="topLeft" title={dataIndex}>
{dataIndex}
</Tooltip>
),
}))
setTableColumns(columnHeaders)
}
}
I have tried doing
render: dataIndex => (
<Tooltip placement="topLeft" title={dataIndex}>
{ {_.isArray(dataIndex) ? dataIndex.map(item => <p className="test">{item}</p>) : null} }
</Tooltip>
),
Which formats the elements in the table, not the tooltip.
Does anyone have any idea on how I can style the elements inside of the span like I did on the table?
I believe you need to use "\n" to break line.
"Hi, my name is Emir." => "Hi, my name is Emir."
"Hi, \n my name is Emir." =>
"Hi,
my name is Emir."
Note: I'm not sure about the answer I wish I could add this as a comment but my reputation is not enough to comment. Have a nice day!
render: dataIndex => (
<Tooltip
placement="topLeft"
title={
_.isArray(dataIndex) ? dataIndex.map(item => <p className="test">{item}</p>) : null
}
>
{dataIndex}
</Tooltip>
),
From reading the docs, looks like title is what is being used to render the elements inside of the tooltip. This gave me what I was after

Working with multiple chainer results in cypress

Since Cypress can't easily use async/await, in order to use multiple chained values, right now I'm doing this:
const getScrubPosition = () => cy.getState().its('meta').its('scrubPosition');
const getScrollBar = () => cy.getByTestId('SCROLL_BAR').then(([bar]) => bar);
const getGutter = () => cy.getByTestId('GUTTER').then(([bar]) => bar);
// my workaround
const getScrubScrollGutter = () => getScrubPosition().then(initialPos =>
getScrollBar().then(([bar]) =>
getGutter().then(([gutter]) =>
({ initialPos, bar, gutter }))));
it('is ridiculous', () => {
getScrubPosition().then(initialPos => {
getScrollBarWidth().then(initialWidth => {
getScrollContainerWidth().then(containerWidth => {
// do something with initialPos, initialWidth, and containerWidth
});
});
});
it('>90 frames, with current series', () => {
clickSeries(1, 3); // x2x4, 94 frames, including pending
getScrubScrollGutter().then(({ initialPos, bar, gutter }) => {
expectPendingShown(true);
expectScrollBar();
// the bar shouldn't be wider than the gutter
expect(bar.offsetWidth).to.be.lessThan(gutter.offsetWidth);
// the right of the bar should be aligned with the right of the gutter
expect(rightEdgeOf(bar)).to.equal(rightEdgeOf(gutter));
debugger
// the bar shouldn't be to the left of the gutter
expect(bar.offsetLeft).to.be.greaterThan(gutter.offsetLeft);
});
There MUST be a better way to do this, right? The github issue mentioned above talks about things like
cy.get('something')
.then(x => doSomethingTo(x))
.then(y => console.log('please help'))
etc. But I'm having a hard time understanding it -- or, if I do understand it, it doesn't actually pass all the values along to the further contexts (i.e., I don't think you can use x in the third line of what I just wrote.)
What about Promise.all?
Yes, I tried that. Please only give a Promise.all related answer if you have actually been able to use it in Cypress.
Thanks.

Adding space between two buttons

I am using haml.erb file. I would like to add space between two buttons in UI. Now the two buttons are appearing one after one without space. How can i do?
= link_to :back, :class => "btn btn-success", :href => '/pt_setup' do
%i.icon-arrow-left.icon-white
Back // does not workout
=link_to "New Subscription", { :controller => "pt_app", :action => "new_subn"}, :class => 'btn btn-success'
you can add margin left on second button. you can add class on second button e.g
=link_to "New Subscription", { :controller => "pt_app", :action => "new_subn"}, :class => 'btn btn-success left-margin'
and then you can add css in your haml file
:css
.left-margin { margin-left: 2px }
Or you can add inline css to one of these buttons.
As you are using Bootstrap
Wrap your buttons in a div with class='col-xs-3' (for example).
Add class="btn-block" to your buttons.
Note: No need to use extra css unnecessary
Your current code puts a space behind the text 'Back', which is inside your link/button, so of course this will not have any affect on the spacing between the buttons themselves.
It has been a while since using haml but something along the lines of:
= link_to :back, :class => "btn btn-success", :href => '/pt_setup' do
%i.icon-arrow-left.icon-white
Back
= link_to "New Subscription", { :controller => "pt_app", :action => "new_subn"}, :class => 'btn btn-success'
Should work in your case.
However, why leave layout / styling to your template at all? use CSS for organizing your layout, put a margin on the right side of .btn class elements, or add a new custom button class and add the margin to limit the scope of buttons affected if you don't want a global margin setting on all buttons.
Try:
= link_to :back, :class => "btn btn-success", :href => '/pt_setup' do
%i.icon-arrow-left.icon-white
Back // does not workout
=link_to "New Subscription", { :controller => "pt_app", :action => "new_subn"}, :class => 'btn btn-success', :style => 'margin-left:10px;'
If you don't want to add a css for spacing. You can add ">" at the end of your brackets for space before and "<" for space after.
Example:
%form
%input{name: "search", placeholder: "Text Here", type: "text"}
%button{type: "submit"}>
%i.fa.fa-search
Will space before the button, separating it from the input text box
Or Equivalently:
%form
%input{name: "search", placeholder: "Text Here", type: "text"}<
%button{type: "submit"}
%i.fa.fa-search
Will space after the input box

Remove drop down content when no data

I have a drop down menu under a bell icon that displays notifications but when there is no data available for it, it displays this on click :
my haml :
%nav.navbar.navbar-default
.container
.navbar-brand= link_to "wat", root_path
- if user_signed_in?
%ul.nav.navbar-nav.navbar-right
%li.nav-item.btn-group{"data-behavior"=>"notifications"}
%a#dropdownMenu1.dropdown-toggle.nav-link{"aria-expanded" => "false", "aria-haspopup" => "true", "data-behavior" => "notifications-link", "data-toggle" => "dropdown", :type => "button"}
= fa_icon "bell"
%span.notifs{"data-behavior" => "unread-count"}
.dropdown-menu{"aria-labelledby" => "dropdownMenu1", "data-behavior" => "notification-items"}
How to remove the little rectangle ?
Check if has data before add .dropdown-menu div
- if hasData?
.dropdown-menu{"aria-labelledby" => "dropdownMenu1", "data-behavior" => "notification-items"}

Telerik Grid ASP.NET MVC2 missing last column separator

My grid has 5 data columns and 1 command column (update/delete)
the column separator between command column and last data column is missing, making everything shift when entering inline edit mode.
Any ideas what am I doing wrong ?
this is the grid's view code:
<%=
Html.Telerik().Grid<ActivityPOCO>()
.Name("ActivityGrid")
.DataKeys(dataKeys =>
{
dataKeys.Add(e => e.ActivityID);
}
.ToolBar(commands => commands.Insert().ButtonType(GridButtonType.Image))
.DataBinding(dataBinding =>
{
dataBinding.Ajax() //Ajax binding
.Select("SelectActivityGridAjax", "Activity")
.Insert("InsertActivityGridAjax", "Activity")
.Update("UpdateActivityGridAjax", "Activity"
.Delete("DeleteActivityGridAjax", "Activity");
})
.Columns(c =>
{
c.Bound(o => o.ActivityID).Title("ID").ReadOnly(true).Width(30);
c.Bound(o => o.ActivityName).Title("NAME").Width(130);
c.Bound(o => o.ActivityTimeHours).Title("TIME").Width(50);
c.Bound(o => o.Cost).Title("COST").Width(100);
c.Bound(o => o.WarrentyMonths).Title("WARRENTY");
c.Command(commands =>
{
commands.Edit().ButtonType(GridButtonType.Image);
commands.Delete().ButtonType(GridButtonType.Image); ;
}).Width(180).Title("COMMAND");
}).Editable(editing => editing.Mode(GridEditMode.InLine))
%>
Well, it looks like a problem in the RTL CSS:
I've changed the .t-last-header{border-right-width:1;} from 0 and got the separator.
Still looking for answer for the grid rows, especially in edit mode...

Resources