How to alter the font-size of the text in a text-box based on its character count in Telerik reporting.
I did the same thing in RDLC using the below query.
=iif(len(Fields!Description.Value) > 20, "8pt", "13pt")
How to map this with Telerik reporting?
There are a couple of ways you can achieve this.
Conditional Formatting Rules
Right-click on your text-box and select Conditional Formatting... Create a new rule and set your condition like this:
Then click on the style builder for this condition and make the font adjustments:
You can add as many rules as you want.
Here's the documentation: https://docs.telerik.com/reporting/expressions-conditional-formatting
HTMLTextBox
The other way to apply conditional formatting is through the use of an HTMLTextBox. There you can include html markup in the value of the box and it will be rendered (with some limitations):
=Iif(Len(Fields.Description) > 20,
"<span style='font-size:8px'>" + Fields.Description + "</span>",
"<span style='font-size:12px'>" + Fields.Description + "</span>")
For more information on that: https://docs.telerik.com/reporting/report-items-html-text-box
Related
I have some special characters in some of my column headers, such as "-" and "*". When these column names are rendered in the Grid, they include a space before and after the sequence.
In other words, if my original string was "CUR-A1" then it would be displayed as "CU R- A1" instead.
Is there any way to disable this kind of auto-formatting?
This turned out to be a pretty simple fix - I was using SharedUtil.camelCaseToHumanFriendly(header) for each header, which introduced the strange formatting.
I'm finding these increasingly harder to manipulate.
is there another way that avoids using the formula bar?
Some text editor that provides indentation perhaps?
You can press:
Ctrl + Enter on Windows
⌘ + Enter on a Mac
inside the formula editor bar to add new lines to your formulas in order to make them more readable.
To comment inside formulas, you can use N().
For example:
=SUM(A1:A)+N("This is a comment.")
this will give exactly the same result as:
=SUM(A1:A)
Note that:
N("This is a comment")
returns 0.
If you want to avoid that, you can use T(N("comment")) which acts like a blank string.
Example:
Probably not the best answer, but as I had the same problem before, what I do is copy the formula to a text editor (or pastebin), ident the formula, select all and then repaste in the google sheets formula. If pasted it will have a line break, like this:
={
ARRAYFORMULA(somecomplicatedstuffhere) ,
ARRAYFORMULA(moreformulashere)
}
Also, if you are inside the cell, you can add a newline this way:
Windows: Ctrl + Enter
Mac/ Linux: ⌘ + Option + Enter
I have a cell that contains a number range, say 50-60 that I would like to apply custom number formatting to. Ideally, I'd like to be able to format that to output 50Hz-60Hz.
The syntax that works for a regular integer is #"Hz", but I can't find an in-built way to do this for dashed ranges, and I suspect it isn't possible.
Answer:
As you suspected, this isn't possible to do.
More Information:
As Tanaike has said in his above comment, the cell input 50-60 is a string - purely read as text as it contains the - character. Resultantly, Sheets does not have the functionality to use Number formatting to change the way this is displayed.
(Kind of) Workarounds:
Disclaimer: These suggestions are not perfect workarounds and depending on how the data in the cells is processed elsewhere in the sheet, these may not work. They do however provide solutions if you are looking to affect the UI only.
Workaround 1: Using a custom Number Format
You can use the format ##"Hz-"##"Hz" which will display 50Hz-60Hz for the example you give, if the input of the cell is 5060 rather than 50-60. You will however need to change the format to contain three # characters if the frequency range of the cell goes above 100:
##"Hz-"##"Hz" will make the number 5060 display as 50Hz-60Hz
###"Hz-"###"Hz" will make the number 120130 display as 120Hz-130Hz
####"Hz-"####"Hz" will make the number 14201430 display as 1420Hz-1430Hz
Workaround 2: Using an onEdit(e) Trigger
If inputting the - yourself is important, then you can use an onEdit() Apps Script trigger to change the format of the cell to include the Hz unit after-the-fact.
For this workaround, I will assume that the column your frequency ranges are in is column C.
From the Tools > Script editor menu item, you can create a function with the following code:
function onEdit(e) {
if (e.range.getColumn() != 3) {
return;
}
else {
var f = e.value.split("-");
e.range.setValue(f = f[0] + "Hz-" + f[1] + "Hz");
}
}
Make sure to change the value on the line if (e.range.getColumn() != 3) to be whichever column your frequency ranges are: this example uses the value 3 because the column is assumed to be column C, but column D would be 4, E would be 5, etc.
Save the script with the save icon, press the run button (►), and confirm the authentication of running the script.
This will automatically run whenever a value like 50-60 is inputted into column C, and will change to display 50Hz-60Hz instead.
Workaround 3: Using a Custom Function
Google Sheets allow you to write custom formulae that work in a similar way to the built in formulae like =SUM() or =COUNT().
Following the same steps as in workaround 2 to open the Script editor, create the following function:
function hertzify(f) {
f = f.split("-");
return f[0] + "Hz-" + f[1] + "Hz";
}
This does a similar thing as workaround 2, but instead of automatically changing the values of whatever is in a specific column, you call the function by entering the following formula in a cell:
=HERTZIFY("50-60")
This will change the cell's display value to 50Hz-60Hz like before.
You can also use this on other cells; for example if cell C3 has the text 120-130 and in cell D3 you input =HERTZIFY(C3), then D3 will display 120Hz-130Hz.
Feature Request:
As the above workarounds either process the cell data as if they are text or require the number to be formatted in a specific way, they might not be perfect workarounds for all situations.
In this case I suggest filing a feature request with Google for the ability to define a number format for a range of values in a specific cell.
You can do this by either following the Help > Report a problem menu item from the Google Sheets user interface, or make a feature request on Google's Issue Tracker asking to implement this as a feature. The link to the Issue Tracker is here
References:
Format numbers in a spreadsheet - Computer - Doc Editors Help
Simple Triggers | Apps Script | Google Developers
Custom Functions in Google Sheets | Apps Script | Google Developers
Google's Issue Tracker
Hi say I have two text fields. I want to have just one maxlength for both of them. Wherein, for example 300 is the maxlength. And that is for both text fields. Is it possible to have 1 maxlength for multiple fields?
Edit:
You will need to use jquery/javascript and client side validation. As a starting point
Something like
$('#text_field_1, #text_field_2').blur(function(){
if($('#text_field_1').val() + $('#text_field_2').val() > 300){
alert("Text Field max length has been reached");
}
});
Building on that example you'll want to have a listener on form submission $().submit that will return false, show an error message, and stop submitting the form if the max length is greater that allowed.
I would like to create a calculated hyperlink that will target a cell within the same document. Insert > Hyperlink allows this option and uses the string #Sheet1!A1, for the Cell A1 on Sheet1, for example.
Is there a way to express this feature as a formula such that it can create the hyperlink based on the result of a calculation?
Yes, there's the HYPERLINK() function:
=HYPERLINK(CONCATENATE("#Sheet1!",T(E2)),"Test")
NB: when working with other language settings then "English (USA)", OOo might require other argument separators (for example: with "German (Germany)", semicolons instead of commas are required).
Split on multiple lines for readability:
=HYPERLINK(
CONCATENATE(
"#Sheet1!",
T(E2)
),
"Test"
)
It will insert a hyperlink, with the target depending on the content of the cell E2. Using the T() function, the Sheet could be set dynamically, too. In my example, E2 could have the value of "A1", resulting in a hyperlink pointing to #Sheet1!A1.
EDIT: Here's a screenshot of a hyperlink with target sheet, target cell and hyperlink text set dynamically:
using this formula:
=HYPERLINK(CONCATENATE("#",T(D1),"!",T(D2)),T(D3))