Pipe and underline between ea number - css

so i have a number lets say 19356 i want it to look like 1|9|3|5|6 and it also to all be underlined. Is this possible without breaking the number and adding a pipe and underline? Also it doesn't have to be a pipe as such just a line between the numbers.

I have a solution your problem. You can achieve it by extending sap.m.FormattedText and handling the functionality as we need as follows.
I will create two files with name SpecialFormattedText and SpecialFormattedTextRenderer as below.
Here is first class that extends FormattedText and has one property number of type int, because you wanted to work with numbers So I choose the int data type.
sap.ui.define(["sap/m/FormattedText"], function (FormattedText) {
"use strict";
return FormattedText.extend("SpecialFormattedText", {
metadata : {
properties : {
number : {
type : "int", defaultValue : null
}
}
},
setNumber : function(iMumber) {
this.setProperty("number", iMumber, true);
this.setProperty("htmlText", this._getUpdatedNumber(iMumber), true);
},
_getUpdatedNumber : function(iMumber) {
return "<U>"+iMumber.toString().match(/.{1}/g).join('|')+"</U>";
}
});
});
Here I will convert the input as we required and setting to the htmlText of FormattedText and maintaining the original value in number. And you can get the original value by using getNumber method provided by SpecialFormattedText class object.
And the next important thing is we are writing the renderer in other class named SpecialFormattedTextRenderer. In this class we will just call the sap.m.FormattedTextRenderer class renderer method as below.
sap.ui.define(["sap/m/FormattedTextRenderer"], function (FormattedTextRenderer) {
"use strict";
var SpecialFormattedTextRenderer = {};
SpecialFormattedTextRenderer.render = function (oRM, oControl) {
oRM.write("<div");
FormattedTextRenderer.render(oRM, oControl);
oRM.write("</div>");
};
return SpecialFormattedTextRenderer;
},true);

Related

Combine NSArrayController with NSTableview method "objectValueFor"

Can I use NSArrayController for my tableview , and using simultaneously this method : ?
func tableView(_ tableView: NSTableView, objectValueFor tableColumn: NSTableColumn?, row: Int) -> Any?
The idea behind:
I do not want to loose the benefits of the arraycontroller ( insert, update, delete ...) but I would like to have control on additional columns to display. The information inside these columns are calculated and formatted; values are coming from the array that the arraycontroller manages (Core Data).
I am afraid this is not possible because controller and tableviewfunction excludes each other ...
Thanks to Willeke, I got it made finally by using a extension for my entity.
extension ImportLog {
// Splits the imported lines into individual words
// For each entity, I split the property "line" .
// Later, in the objc computed property, I pick column number x
var splittedText:[String.SubSequence]{
return(self.line!.split(separator: ";"))
}
// col1
#objc var f1: String {
get {
let theColumn = 0
var text:String = ""
if ( splittedText.count-1 >= theColumn) {
text = String(splittedText[theColumn])
}
return text
}
set {
// no need to set something
}
}
}
The computed property "f1" of the entity can now be bound in the XIB file
by "Table Cell View.objectValue.f1"

Serilog Custom Sink Formatting Issue with Serilog LogEventPropertyValue

I'm having to create my own custom sink because none of the ones currently available give me what I need.
Issue I have is when fetching the key/value pair Value from the logEvent message in the Emit Method, the value is wrapped with quotation marks & backslashes.
I've tried converting the out value from the dictionary into a string and then removing the unwanted attributes but nothing is working for me.
Method in my Custom Sink Class:
public void Emit(LogEvent logEvent)
{
var properties = logEvent.Properties;
Serilog.Events.LogEventPropertyValue value;
if (properties.TryGetValue("logEventCategory", out value))
{
// Regex.Replace((value.ToString() ?? "").Replace("'", #"\'").Trim(), #"[\r\n]+", " "); // Not working
var notWorking = value.ToString();
var formattedValueNotWorking = value.ToString().Replace("\r\n", "\\r\\n");
}
}
It just seems that any attempted formatting of the key/value pair Value is ignored: You see that the example string value System is wrapped with a \"System\"
All I want is the actual string, not the backslashes or quotation marks that is wrapped around the string.
Creating my own sink is a hard enough task and I just want to keep things simple, have spent two days trying to understand the wider picture in message formatting but with custom sinks it gets too complicated and bloated coding for what I need. All the other standard message structure attributes are rendering OK, such as message / level / timestamp etc, it's just fine tuning the rendering of the propertie values I require in order to save these values into their own columns in my DB.
You need to unwrap the string from the enclosing ScalarValue:
// using Serilog.Events;
public void Emit(LogEvent logEvent)
{
var properties = logEvent.Properties;
Serilog.Events.LogEventPropertyValue value;
if (properties.TryGetValue("logEventCategory", out value) &&
value is ScalarValue sv &&
sv.Value is string rawValue)
{
// `rawValue` is what you're looking for
Looks like I just needed to use the correct syntax for string replace:
public void Emit(LogEvent logEvent)
{
var properties = logEvent.Properties;
Serilog.Events.LogEventPropertyValue value;
if (properties.TryGetValue("logEventCategory", out value))
{
var formattedValueWorking = value.ToString().Replace("\"", "");
var test = formattedValueWorking;
}
}

GXT -coloring entire grid row according to one cell in row

. .
I colored one column according to the value of cell but i want to color the entire row (means the cell contained row ) in gxt grid help me
here is my code for coloring the cell (i want to color the row instead of the cell)
/*------------Coloring Area------------*/
GridCellRenderer<BeanModelType> ColoredGrid = new GridCellRenderer<BeanModelType>() {
#Override
public Object render(BeanModelType model,
String property, ColumnData config,
int rowIndex, int colIndex,
ListStore<BeanModelType> store,
Grid<BeanModelType> grid) {
String valueOfCell = model.get(property);
String style = valueOfCell.equals("Book") ? "GREEN":
valueOfCell.equals("Ersr") ? "red":
valueOfCell.equals("Pen") ? "yellow":
valueOfCell.equals("comp") ? "blue": "";
//Config is the cell and we are setting style here
config.style ="background-color:"+style;
return valueOfCell;
}
};
System.out.println("COLORRRRR "+cleanColoredGrid.toString());
column.setRenderer(ColoredGrid);
/*-------------Coloring Area Ends-------*/
configs.add(column);
Given you are using GXT > 2.x.x, the correct way to do this is to attach a new GridViewConfig to your grid's view.
You should probably do something like:
grid.getView().setViewConfig(new GridViewConfig() {
#Override
public String getRowStyle(ModelData model, int rowIndex, ListStore<ModelData> ds) {
if (model != null) {
//TODO: put your conditions here
if ("YOUR_CONDITION".equals(model.get("BOOK_COLOR))) {
return "green-row";
}
}
return "";
}
});
You should amend your css accordingly. (note that green-row is a name of a css style class).
See this for reference: http://www.jarvana.com/jarvana/view/com/extjs/gxt/2.1.1/gxt-2.1.1-javadoc.jar!/gxt-2.1.1-javadoc/com/extjs/gxt/ui/client/widget/grid/GridViewConfig.html
In every render method you got model as one of parameter, so try to set the same renderer to each column, but replace 'property' to name of attribute which holds string with type of item. Let's suppose you called it 'itemName', so change your code to:
model.get("itemName");
Maybe casting will be required, because model.get() should return Object.
Now in every column the same check will be performed and all of them should be in one color.
If that will work, next step could be some optimizations: if first check returns some color, set it into hashmap of model-to-color (or into the model directly as a new attribute) and add in the renderer a condition which will check if color wasn't already assigned.

Use variable name in StringUtil.substitue in Actionscript

If I have the following code:
var value : String = StringUtil.substitute("The value {0} requested is {1}", user, value);
How can I use the variable name instead of using {0} and {1} in the code.
Please advice. Thanks.
Edit:
The above code is quoted from http://www.rialvalue.com/blog/2010/05/10/string-templating-in-flex/.
It says that "Also note that we’re substituting the parameters using the order, it’d would fairly easy to do a named-parameter subsitution instead (i.e. using tokens like ${var1})". Therefore, I think it may be very easy to do that, but I don't know how to do.
Looks like it's not possible. And kind of makes sense that it allows zero based ints only, since you're passing a variable number of parameters that you're not identifying (except for their relative position in the params list).
Here's a piece of code that will replace tokens by name:
public static function replacePlaceholders(input:String,replacementMap:Object):String {
// '${', followed by any char except '}', ended by '}'
return input.replace(/\${([^}]*)}/g,function():String {
return replaceEntities(arguments,replacementMap);
});
}
private static function replaceEntities(regExpArgs:Array,map:Object):String {
var entity:String = String(regExpArgs[0]);
var entityBody:String = String(regExpArgs[1]);
return (map[entityBody]) ? map[entityBody] : entity;
}
Use:
var test:String = "Hello there ${name}, how is the ${noun} today?";
var replacementMap:Object = {
name : "YOUR_NAME_HERE",
noun : "YOUR_NOUN_HERE"
};
trace(StringUtils.replacePlaceholders(test,replacementMap));
The format I'm using for the placeholders is ${placeholdername}, since it's safer, I think. But if you want to remove the dollar sign, change the regexp accordingly.

How to resize columns of DataGrid bound to List<T>, not DataSet?

I'm trying to use a System.Windows.Forms.DataGrid control in my Compact Framework 3.5 Window Mobile Professional 6 SDK based project to show some properties of objects of type Something by binding the DataGrid to a List<SomethingWrapper> instance like this:
public class SomethingWrapper {
private Something data;
public SomethingWrapper(Something data) { this.data = data; }
public string Column1 { get { /* string from this.data */ } }
public string Column2 { get { /* string from this.data */ } }
}
public class SomethingList : List<SomethingWrapper> {
public SomethingList(IEnumerable<Something> items) {
foreach (var item in items) Add(new SomethingWrapper(item));
Sort((a, b) => a.Column2.CompareTo(b.Column2);
}
}
/* ... */
IEnumerable<Something> dataToShow = /* assume this is filled correctly */
SomethingDataGrid.DataSource = new SomethingList(dataToShow);
This seems to work fine: the correct data is shown in the grid with two columns called Column1 and Column2 and sorted on the second column. I want this to be a readonly view of this data, so all is fine.
However, I would like to set column widths and cannot seem to get this to work...
Have tried to obvious: creating TableStyle, creating textbox column style instance per column, adding it to the TableStyle and setting SomethingDataGrid.TableStyle to resulting table style. (This is from memory, or I would also show the exact code I'm using. If needed, I can add that to the question somewhere later today.)
Nothing changes however. I suspect this has something to do with the MappingName on the TableStyle object; all examples I could find yesterday evening seem to be for databinding a DataSet to the DataGrid and setting MappingName to the correct table name in the DataSet. Otherwise, the table style will not do what you expect, which is the behavior I'm seeing.
Question: am I looking in the correct place for a solution to my problem, and if so, what do I need to set TableStyle.MappingName to when binding to a List<T> to show properties of T...?
(Tried to check for possible duplicates, but was unable to find exact matches. Please correct me if I turn out to be wrong there.)
Ah, didn't look well enough after all: duplicate question found. Will try deriving from BindingList<T> and/or using a binding source so I can start calling BindingSource.GetListName(null) to get a MappingName. Hope this will help. If not, I'll be back...
You can do this by creating a DataGridTableStyle
Here is an extension method that I use:
public static void SetColumnStyles<T>(this DataGrid ctrl, T data, params ColumnStyle[] column) where T: class
{
var ts = new DataGridTableStyle();
ts.MappingName = data.GetType().Name;
foreach (var style in column)
{
ts.GridColumnStyles.AddColumn(style.Header, style.Column, style.Width);
}
ctrl.TableStyles.Clear();
ctrl.TableStyles.Add(ts);
}
Then I call it like this:
var newList = queriableData.ToList();
ProductEdit.DataSource = newList;
ProductEdit.SetColumnStyles(newList, new[]
{
new ColumnStyle("Name", 200),
new ColumnStyle("Manufacturer", 100),
new ColumnStyle("Size", 20)
});
where newList is a generic list of objects.

Resources