I need to use a JavaFX 2.2 TreeView control inside a larger scrollpane that has several other elements which are not part of the Treeview. The problem is that TreeView has its own built-in scrollpane. Does anyone have an example of a way to turn off the built-in scrollpane so that the TreeView grows as large as the items contained within it?
While it is not currently possible to remove the scroll bars, it IS possible to mostly hide them with CSS.
.your-selector *.column-header-background *.show-hide-columns-button,
.your-selector *.scroll-bar:vertical *.increment-button,
.your-selector *.scroll-bar:vertical *.decrement-button,
.your-selector *.scroll-bar:vertical *.increment-arrow,
.your-selector *.scroll-bar:vertical *.decrement-arrow {
-fx-background-color: null;
-fx-background-radius: 0;
-fx-background-insets: 0;
-fx-padding: 0;
-fx-shape: null;
}
.your-selector *.scroll-bar:horizontal,
.your-selector *.scroll-bar:horizontal *.track,
.your-selector *.scroll-bar:horizontal *.track-background,
.your-selector *.scroll-bar:horizontal *.thumb,
.your-selector *.scroll-bar:horizontal *.increment-button,
.your-selector *.scroll-bar:horizontal *.decrement-button,
.your-selector *.scroll-bar:horizontal *.increment-arrow,
.your-selector *.scroll-bar:horizontal *.decrement-arrow {
-fx-base: transparent;
-fx-background-color: white;
}
This is a great question.
I think you need to create your own TableViewSkin which does not derive from the VirtualContainerBase. VirtualContainerBase manages a VirtualFlow, which you don't want if you want the entire TreeView to display. I believe this is a rather tricky thing to accomplish in a general way within the JavaFX 2/8 API and do not have any sample solution or further suggestions on how to accomplish this at this time.
There is an existing feature request for such functionality in the JavaFX issue tracker:
RT-26631 "Allow scrolling to be disabled on Controls like Table, List, Tree and TreeTable".
Currently, the feature has not been scheduled for implementation in a future release.
In my application I just wanted to remove the horizontal scrollbars. The answer of robross0606 was very useful to me, but it turns out only the following was necessary in my case:
.scroll-bar:horizontal,
.scroll-bar:horizontal *.increment-button,
.scroll-bar:horizontal *.decrement-button,
.scroll-bar:horizontal *.increment-arrow,
.scroll-bar:horizontal *.decrement-arrow {
-fx-padding: 0;
}
Related
I am working with Telerik Word Processing (WP) and in some instances the HTML output on screen has a line strike through to show that an event is cancelled.
Because of how the WP works, it cannot use CSS in the standard way using links and relative paths so am using style tags in the CSHTML file.
If in the page I use
.cancelled-event {
color: #c82333;
text-decoration: underline !important
}
The text is underlined and is coloured correctly, if I use
.cancelled-event {
color: #c82333;
text-decoration: line-through !important
}
I just get the text the right colour.
Overline also does not work, however only tested this to ensure that Im not being an idiot (doesn't mean Im not, but still one of the easy checkables)
What I would like help with is,
Has anyone else experienced this? If so how did you resolve it,
What other suggestions, is there to get
The CSHTML page is as below, munis code that will bloat this question.
<style>
.date-selection {
border: 1px solid #8c8c8c;
background-color: #ffffff
}
.cancelled-event {
color: #c82333;
text-decoration: line-through !important
... more styles here...
}
</style>
<img src="http://localhost:8001/images/logo.png" />
<br/>
<partial name="~/Views/Roster/_RosterAgenda.cshtml" model="#Model" />
I konw the strike through does show in 2/3 scenarios.
In view - works
In view where export should be as I have an exit where I can push the data to a view before pdf - works
In PDF - doesnt work.
PDF Generation is being done like this, the byte array that is passed in is base 64 encoded as the original file information is being passed from one System to an API over the wire.
public byte[] ConvertHtmlToPdf(byte[] fileData, string extension, PageSettings.PageOrientation orientation)
{
byte[] convertedData = null;
var base64EncodedBytes = Convert.FromBase64String(Encoding.Default.GetString(fileData));
var html = Encoding.UTF8.GetString(base64EncodedBytes);
HtmlFormatProvider htmlProvider = new HtmlFormatProvider();
RadFlowDocument document = htmlProvider.Import(html);
IFormatProvider<RadFlowDocument> provider = this.providers
.FirstOrDefault(p => p.SupportedExtensions
.Any(e => string.Compare(extension, e, StringComparison.InvariantCultureIgnoreCase) == 0));
if (provider == null)
{
Log.Error($"No provider found that supports the extension: {extension}");
return null;
}
var quality = Telerik.Windows.Documents.Fixed.FormatProviders.Pdf.Export.ImageQuality.Medium;
PdfFormatProvider formatProvider = new PdfFormatProvider();
formatProvider.ExportSettings.ImageQuality = quality;
if (document.Sections.Any())
{
foreach (var section in document.Sections)
{
//section.PageOrientation = orientation == PageSettings.PageOrientation.Landscape ? PageOrientation.Landscape : PageOrientation.Portrait;
section.Rotate(orientation == PageSettings.PageOrientation.Landscape ? PageOrientation.Landscape : PageOrientation.Portrait);
}
}
using (var stream = new MemoryStream())
{
formatProvider.Export(document, stream);
convertedData = stream.ToArray();
}
return convertedData;
}
I found a better, easier, nicer way, but this only works if you have the Kendo Tools license too.
$(".export-pdf").click(function() {
// Convert the DOM element to a drawing using kendo.drawing.drawDOM
kendo.drawing.drawDOM($(".content-wrapper"))
.then(function(group) {
// Render the result as a PDF file
return kendo.drawing.exportPDF(group, {
paperSize: "auto",
margin: { left: "1cm", top: "1cm", right: "1cm", bottom: "1cm" }
});
})
.done(function(data) {
// Save the PDF file
kendo.saveAs({
dataURI: data,
fileName: "HR-Dashboard.pdf",
proxyURL: "https://demos.telerik.com/kendo-ui/service/export"
});
});
});
As per usual Telerik documentation is awful, and to find anything you want you almost have to start looking for something else. However, this code was found at
https://www.telerik.com/blogs/5-ways-export-asp-net-word-pdf-file
The benefit of this, and once again this only works if you have UI for xxx. In this instance I am using UI for ASP.Net Core and also using Typescript which needed a modification to the definately typed file kendo.all.d.ts too.
function drawDOM(element: JQuery, options: any): JQueryPromise<any>; //Existing code in the d.ts file
function drawDOM(element: JQuery<HTMLElement>);
function drawDOM(element: any, options?: any): JQueryPromise<any>;
But this is \ was down to not passing in a type of jquery object of HTMLElement. This makes it a little more robust enabling you to pass more into it.
I suspect that this answer will only be of use to a small number of people, however, hopefully this will help someone in the future.
The menu is fixed and will follow on scroll. This does not work well with touch devices.
I want to call the script, using Modernizr, when it detect no-touch devises. But I'm unsure how to do this.
Also, is there elements from the Modernizr download-page that I need to accomplish this?
Here is my script:
$(document).ready(function() {
$(window).scroll(function() {
var header = $('#fixed-bar').outerHeight(true);
console.log(header);
var scrollTopVal = $(this).scrollTop();
if ( scrollTopVal > header ) {
$('nav').css({'position':'fixed','top' :'0px', 'border-bottom':'4px solid #ff5454'});
} else {
$('nav').css({'position':'absolute','top':'90px', 'border-bottom':'none'});
}
});
});
But I'm unsure how to do this.
You don't want to just use javascript, you want to use mostly css, and just toggle classes with javascript. Its more performant (which is super important with something like scroll loops).
#fixed-bar {
position: fixed;
top: 0px;
border-bottom:4px solid #ff5454;
}
.touch #fixed-bar, #fixed-bar.at-top {
top: 90px;
border-bottom: none
}
also, you don't want to directly attach to window.scroll. Instead, you want to use requestAnimationFrame (shimming where needed) to get the most buttery smooth animations possible. Here is a coffeescript example for jQUery.With that, you would be looking to do something like this
$(document).ready(function() {
// the height doesn't change, so we don't need to look it up on scroll.
var headerHeight = $('#fixed-bar').outerHeight(true);
$.request_scroll(function() {
var scrollTopVal = $(this).scrollTop();
if ( scrollTopVal > headerHeight ) {
$('nav').addClass('at-top');
}
else {
$('nav').removeClass('at-top');
}
});
Also, is there elements from the Modernizr download-page that I need to accomplish this?
just the Modernizr.touch test.
Be warned, this doesn't detect touch screens, just devices that support touchevents. That means new windows 8 laptops will be detected as .touch, and windows phones will not (they use pointer-events, not touch events).
I now have a fiddle with help from Patricks answers, but as you can see, the bar does still not go to the top, when you scroll as it should, like on my website.
Is there a solution for this? Tablets and phones don't like effects, which have $(window).scroll(function().
Currently I have this javascript on my website (the id's are different):
$(document).ready(function() {
$(window).scroll(function() {
var header = $('#fixed-bar').outerHeight(true);
console.log(header);
//this will calculate header's full height, with borders, margins, paddings
var scrollTopVal = $(this).scrollTop();
if ( scrollTopVal > header ) {
$('nav').css({'position':'fixed','top' :'0px', 'border-bottom':'4px solid #ff5454'});
} else {
$('nav').css({'position':'absolute','top':'90px', 'border-bottom':'none'});
}
});
});
While most tablets have problems with $(window).scroll(function(), it works on desktop pc. Not much consolation though.
Is there an alternate way of getting this to work? Using touch- and pointer events, maybe someone has a working fiddle og example?
I am curious as to how to do this, I want to send a custom error message for forums and for regular views from a controller to a view (thus looking for examples of both). I have seen ModelState.AddError() how ever I am looking to control the look the error message that is be able to wrap it in divs on the front end.
any ideas?
I am very new to ASP.net and the tutorials out there for this seem very confusing to me. So I don't really have any code to show as I am not sure what I am suppose to do.
I believe you are looking to customize the error message on your view. You can customize the error messages including the ones you added using ModelState.AddModelError("", "error message") in three ways.
Option 1
Use Html.ValidationSummary() and customize its look via the validation-summary-errors class. The default mvc project template in VS will include that class by default. It has a default color of red (I think). But you can practically control every aspect of the error summary by changing that class.
.validation-summary-errors {
border: 5px solid red; // thick red border
color: #3904D9; // dark blue
font-size: 1.5em; // quite big fonts
font-weight: bold;
}
Option 2
The ValidationSummary outputs the messages in an unordered list (li). If your project calls for a different way of showing the error messages, you can do it on the view by inspecting the ViewDataDictionary. The following code will write the error messages in separate divs with a thin red border. The style is written inline to make the sample simple.
#foreach (var item in ViewData.ModelState) {
if (item.Value.Errors.Any()) {
foreach (ModelError e in item.Value.Errors) {
<div style="border: 1px solid red;margin-bottom:5px;">
#e.ErrorMessage</div>
}
}
}
Option 3
If you do not want to put logic on your view, then you can extend the htmlhelper (or create a custom helper). You basically will use the same logic shown in Option 2 in the custom htmlhelper.
public static class HtmlExtensions {
public static MvcHtmlString CustomValidationSummary(this HtmlHelper helper)
{
var html = string.Empty;
foreach (var item in helper.ViewData.ModelState)
{
if (item.Value.Errors.Any()) {
foreach (ModelError e in item.Value.Errors) {
html
+= "<div style='border: 1px solid red;margin-bottom:5px;'>"
+ e.ErrorMessage
+ "</div>";
}
}
}
return MvcHtmlString.Create(html);
}
}
And then you use it the same way as you will use the ValidationSummary:
#Html.CustomValidationSummary()
You may want to look into the ViewBag object. If you set ViewBag.ErrorMessage in your controller, it will be available as a string in your view. And, actually, you can name it whatever you want, not just ErrorMessage.
Add this and include logic in your view to only display if !string.IsNullOrEmpty(ViewBag.ErrorMessage) and you should be good.
This is only one of multiple ways to do it. ViewBag is just a wrapper on ViewData, so if you are stuck, you may want to look into that object also.
While this answer is not fully comprehensive, hopefully it will give you a place to start.
Best of luck!!
Can i add Red Border to Kendo UI date picker if validation fails
function onChange(e) {
if (e.date == undefined) {
var item = $(this).find('.t-input').val('Incorrect date!');
}
}
I have this onChange Method and trying to add red border. Can anyone help me or suggest a better solution
Adding this CSS should work:
#datepicker[aria-invalid] {
border: 1px solid #f00;
}
Here is an example:
jsbin.
Unfortunately, you cannot do this with Kendo UI.
Kendo UI elements do not allow you to do this.
I did data binding with the style sheets on a kendo widget.
Firebug will inform you that it is not possible.
I will open a ticket with my telerik support account now and come back to you.
I would also like to do the same thing.
$('input[aria-owns=txt-orderedTime_timeview]').closest(".k-picker-wrap.k-state-default").css("border-color", '#ff0000');
OR
$("#txt-orderedTime").data("kendoTimePicker").wrapper.find(".k-picker-wrap.k-state-default").addClass("validationErrorClass");
.validationErrorClass {
border-color: #ff0000 !important;
}
I have a 'responsive' website but there are some links I only want on 'pc browsers' only and not on 'tablet landscape' becasue they link off to flash objects.
So far this is what I have done but it't not a 100% fix as some android tablets such as 'Lenovo think pad' which have a bigger screen.
I am using media queries to make my site responsive and this is what I'm currently using...
#media only screen
and (max-device-width : 1024px)
and (orientation:landscape)
{
header.Site
{
nav.Site > ul > li { line-height: 2 ; }
div.BidSessionCountdown,
a.LiveOnline { display: none; }
}
}
Is there any CSS fixes you can think of?
Thank you in advance
Tash :D
Using media queries isn't really the appropriate technique to detect if flash is supported or not. My suggestion would be to determine this using JavaScript, and assign a class to the body element such as "no-flash". Your JavaScript might look like this:
//Using jQuery here
if(typeof navigator.plugins['Shockwave Flash'] == 'undefined') {
$('body').addClass('no-flash');
}
Then, your CSS could be as follows:
body.no-flash a.LiveOnline {
display:none;
}
Note: The javascript code that checks the navigator plugin comes from Here.
When you are using the orientation:landscape, you have to consider whether the keyboard popup will change the display, once the width size is larger than the height size, the css will consider it as landscape.