How to Format DataTable Column after load Datatable without extra loop ??
How to Format Column after load Datatable without extra loop ??
I dont want to do extra logic which can cause performance thing.
I have datatable which get fill from Dataset after database query, now i need to format column as decimal but without extra logic.
I was thinking to create clone and than Import row loop but it ll kill performance, its WPF application.
Thanks
Jumpingboy
You cannot do any custom things at all without doing some "extra logic". Formatting a number as decimal is certainly not a performance killer in any way whatsoever though.
If you are displaying the contents of the DataTable in a DataGrid you could specify a StringFormat in the XAML:
<DataGrid x:Name="dg1" AutoGenerateColumns="False">
<DataGrid.Columns>
<DataGridTextColumn Header="Number" Binding="{Binding num, StringFormat=N2}"/>
</DataGrid.Columns>
</DataGrid>
Or if you are using auto-generated columns you could handle the AutoGeneratingColumn event:
public MainWindow() {
InitializeComponent();
DataTable table1 = new DataTable();
table1.Columns.Add(new DataColumn("num")
DataType = typeof(decimal)
table1.Rows.Add(1.444444444444);
table1.Rows.Add(7.444444444444);
dg1.ItemsSource = table1.DefaultView;
dg1.AutoGeneratingColumn += dg1_AutoGeneratingColumn;
void dg1_AutoGeneratingColumn(object sender, DataGridAutoGeneratingColumnEventArgs e) {
if (e.PropertyName == "num") {
DataGridTextColumn column = e.Column as DataGridTextColumn;
column.Binding.StringFormat = "N2";
<DataGrid x:Name="dg1" />
Please remember to mark helpful posts as answer and/or helpful.
Similar Messages
-
How to move flat file after loading in owb to other directory with othernam
Hi All,
I wast struck in problem . after loading the flat file in owb that file should be move or rename or zip with Date everyday .
I dont know how to achieve this issue in owb via proceudre or any other way ... .
how to zip files from pl/sql procedure ...... with sysdate.zip.
any one please help me in this problem to come out soon.
thanks ,
murariOne way is to use a Java stored procedure, this can then be called from a map or a process flow. The Java stored procedure will use the Zip capabilities in Java to do what you need. For example you will need the following procedure and you will have to grant privileges for your file to ZIP and the entire directory for zipping into (since the file name will be dynamic):
For example grant YOURSCHEMA (change to your tgt schema) read on your extract directory where your file to zip is and write on your zips directory (where the zips will go);
exec dbms_java.grant_permission('YOURSCHEMA', 'SYS:java.io.FilePermission', 'c:\staging\extracts\*','read');
exec dbms_java.grant_permission('YOURSCHEMA', 'SYS:java.io.FilePermission', 'c:\staging\zips\*', 'write' )
You can then create your procedure which you can invoke
CREATE OR REPLACE AND COMPILE JAVA SOURCE NAMED "otnZipFile"
AS
import java.util.zip.ZipEntry;
import java.util.zip.ZipOutputStream;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
public class otnZipFile
public static void zipFile(String zip, String filename)
byte[] buf = new byte[1024];
try {
String outFilename = zip;
ZipOutputStream out = new ZipOutputStream(new FileOutputStream(outFilename));
FileInputStream in = new FileInputStream(filename);
out.putNextEntry(new ZipEntry(filename));
int len;
while ((len = in.read(buf)) > 0) {
out.write(buf, 0, len);
out.closeEntry();
in.close();
out.close();
} catch (IOException e) {
create or replace PROCEDURE zip_file(
dir IN VARCHAR2,
file_name IN VARCHAR2) IS
LANGUAGE JAVA NAME 'otnZipFile.zipFile(java.lang.String, java.lang.String)';
For example here I zip a file MYCSV.csv into the zip file MYZIP.zip
exec zip_file('c:\staging\zips\MYZIP.zip', 'c:\staging\extracts\MYCSV.csv');
Cheers
David -
How to make Matlab work after loading Yosemite ?
How to make Matlab work after leading Yosemite on a Macbook pro ?
R2014b should work with Yosemite. What version do you have?
-
How to increase BoundingSphere radius after loading .3ds model
I can properly load in all .3ds models, however, after loading them into the canvas some .3ds models are far too large. When I zoom out (by pushing the model back with MouseZoom) the model disappears from view even though I have the boundingsphere declared as:
BoundingSphere bounds = new BoundingSphere(new Point3d(), Double.POSITIVE_INFINITY);
I add the loaded model (transformgroup.addChild(model.getSceneGroup());) and this contains the bounds as shown above.
The weird thing is when I load .obj files using the same method it works fine. I can zoom out on these objects to infinity (until they are small dots).
Why are the .3ds models disappearing from the bounds even when I have them set to POSITIVE INFINITY?
Any ideas? Thanks.Try the Java 3D forum: [http://forums.sun.com/forum.jspa?forumID=21]
-
How to insert additional column header using dataTable
Hi everyone, I am using MyFaces 1.1.3, tomahawk 1.1.3, tomahawk-sandbox 1.1.5
I have to add one column header "Proficiency" as in image [http://www.nabble.com/file/p17206601/screenshot.jpg]
This is JSF code without "Proficiency":
<t:dataTable id="data" value="#{commonBean.tableList}" styleClass="standardTable" headerClass="table_header" rowClasses="table_row1, table_row2" columnClasses="standardTable_Checkbox_Column,standard_text,standardTable_Checkbox_Column,standardTable_Checkbox_Column" var="value" preserveSort="true" rows="10" width="100%" border="0" sortColumn="#{commonBean.sortColumn}" sortAscending="#{commonBean.ascending}" cellpadding="2" cellspacing="1" rowIndexVar="tableRowIndex">
<h:column>
<f:facet name="header">
<h:panelGrid styleClass="table_header2">
<h:outputText value="#{msg['select']}" />
</h:panelGrid>
</f:facet>
<h:selectBooleanCheckbox id="select" value="#{value.select}" />
</h:column>
<h:column>
<f:facet name="header">
<t:commandSortHeader columnName="languageSkill" arrow="true" styleClass="table_header">
<h:outputText value="#{msg['language.skill']}" />
</t:commandSortHeader>
</f:facet>
<h:commandLink action="#{commonBean.editAction}" actionListener="#{commonBean.editActionListener}">
<h:outputText value="#{value.languageSkill}" />
</h:commandLink>
<f:param id="object" value="#{value}" />
</h:column>
<h:column>
<f:facet name="header">
<h:outputText value="#{msg['spoken']}" />
</f:facet>
<h:outputText value="#{value.spokenDescription}" styleClass="standardText"/>
</h:column>
<h:column>
<f:facet name="header">
<h:outputText value="#{msg['written']}" />
</f:facet>
<h:outputText value="#{value.writtenDescription}" styleClass="standardText"/>
</h:column>
</t:dataTable>How to do ?
Thanks for your help
Edited by: nvduc82 on May 13, 2008 12:09 PM
Edited by: nvduc82 on May 13, 2008 8:46 PMI see 2 possibilities:
1. Merge two last columns. And then use panelGrid inside the cells.
2. Use JSTL and tag forEach. I found it much easy-to-use. -
How to format numeric result in a datatable?
I have a View Object (not tied to an Entity Object) that is displaying a read-only table that includes numeric values.
I'm not able to figure out how to control the display formatting so that only 1 decimal place is shown - right now the numbers are showing more than 10 decimal places.
Is there anyway to control the display format for numerics using either the View Object Editor Properties, or, through using attributes of the <af:outputText> tag on the .jspx page?
Here is what I have defined currently:
In the View Object Editor, the numeric columns are defined as:
View Attribute Tab: Type=Big Decimal
Control Hints Tab: Format Type=Number; Format = ####.## (question does this formatting only apply when editing the field, or also should it apply when I'm reading/displaying from the database?)
In .jspx page:
<af:column headerText="#{bindings.ZipCodeTestView1.labels.Latitude}"
sortProperty="Latitude" sortable="true">
<af:outputText value="#{row.Latitude}"/>
</af:column>
thanks
Tomhmmm.. I had tried that. What I'm noticing now is that if I test the VO in the BC4J tester within Jdev the format mask is applied. However, when I add the table (as readonly) to a .jspx page and deploy to Tomcat, the format mask is not used when I view the page in Firefox 1.5.0.3 (or Internet Explorer 6.0)? Any ideas?
here's a snippet for one of the columns from the .jspx page:
<af:column headerText="#{bindings.ZipCodeTestView1.labels.Latitude}"
sortProperty="Latitude" sortable="true">
<af:outputText value="#{row.Latitude}"/>
</af:column>
Message was edited by:
javaX -
I want to access Yahoo's toolbar & am told that I must switch over to Firefox. I just want to know if this is going to cause any problems or change things. In other words, is it seamless?
I want to access Yahoo's toolbar & am told that I must switch over to Firefox. I just want to know if this is going to cause any problems or change things. In other words, is it seamless?
-
How to Format DataGridView Cells after user input, also find average of Timespans
I'm a rather new to programming and slowly learning as best I can, and feel that I'm probably just getting hung up on some things because of my lack of overall understanding. I've searched plenty online and these forums to figure out my issues, but
somethings just go over my head or I can't figure out how to make it work for what I'm trying to do.
On to what I'm trying to do.
I'm working on building an app for scoring swim meets for our conference. I'm using a lcal SQL DB for all of the data and have a DGV on my form. We don't have timing systems so we take 2 times from stop watches and then need to do an average
of the times to determine a swimmers time. I have 3 fields for times, Time1, Time2 and AvgTime.
What I'm needing help with is how do I allow the user to not worry about formatting the time they enter but have it automatically format what they input after they exit the cell on Time1 and Time2. Then I need to have it figure out the average of those
two times in AvgTime cell. I'm able to get the averaging to work if I have the datatype set to decimal or int, but I can't get it to work if I have them set has TimeSpan.
Below is the code I have currently. As you can see I've got things commented out that I found online but couldn't make work.
Thanks for taking the time to review this and help me out.
Public Class EventScoring
Private Sub EventScoring_Load(sender As Object, e As EventArgs) Handles MyBase.Load
'TODO: This line of code loads data into the 'MeetDataSet.DualLineup' table. You can move, or remove it, as needed.
Me.DualLineupTableAdapter.Fill(Me.MeetDataSet.DualLineup)
'TODO: This line of code loads data into the 'MeetDataSet.EventList' table. You can move, or remove it, as needed.
Me.EventListTableAdapter.Fill(Me.MeetDataSet.EventList)
'DualLineupDataGridView.Columns(5).DefaultCellStyle.Format = ("mm\:ss\.ff")
MeetDataSet.DualLineup.Columns("AvgTime").Expression = "(([Time1] + [Time2]) /2)"
End Sub
Private Sub Sub_Btn_Click(ByVal sender As Object, ByVal e As EventArgs) Handles Sub_Btn.Click
Try
Me.Validate()
Me.DualLineupBindingSource.EndEdit()
Me.DualLineupTableAdapter.Update(Me.MeetDataSet.DualLineup)
MsgBox("Update successful")
Catch ex As Exception
MsgBox("Update failed")
End Try
End Sub
'Private Sub DualLineupDataGridView_CellFormatting(ByVal sender As Object, ByVal e As DataGridViewCellFormattingEventArgs) Handles DualLineupDataGridView.CellFormatting
' If ((e.ColumnIndex = 5) AndAlso (Not IsDBNull(e.Value))) Then
' Dim tp As TimeSpan = CType(e.Value, TimeSpan)
' Dim dt As DateTime = New DateTime(tp.Ticks)
' e.Value = dt.ToString("mm\:ss\.ff")
' End If
'End Sub
'Private Sub DualLineupDataGridView_CurrentCellDirtyStateChanged(ByVal sender As Object, ByVal e As DataGridViewCellFormattingEventArgs) Handles DualLineupDataGridView.CurrentCellDirtyStateChanged
' If ((e.ColumnIndex = 5) AndAlso (Not IsDBNull(e.Value))) Then
' Dim tp As TimeSpan = CType(e.Value, TimeSpan)
' Dim dt As DateTime = New DateTime(tp.Ticks)
' e.Value = dt.ToString("mm\:ss\.ff")
' End If
'End Sub
End ClassAB,
If you're ok with your database other than working out this issue with time, you might want to give the following a try. It's pretty flexible in that you can give it a string or a decimal, and I'll explain:
The string can be in the format of "mm:ss" (minutes and seconds) or in the format of "mm:ss:f~".
The reason that I put the tilda there is because you're not limited on the number of decimal places - it will work out the math to figure out what you meant.
Also though, you can give it a decimal value representing the total number of seconds. Do be sure to clearly denote that it's a decimal type (otherwise it will assume it's a double and will fail). Here's the class:
Public Class SwimmerTime
Private _totalSeconds As Decimal
Public Sub New(ByVal value As Object)
Try
Dim tSeconds As Decimal = 0
If TypeOf value Is String Then
Dim s As String = CType(value, String)
If Not s.Contains(":"c) Then
Throw New ArgumentException("The string is malformed and cannot be used.")
Else
Dim elements() As String = s.Split(":"c)
For Each element As String In elements
If Not Integer.TryParse(element, New Integer) Then
Throw New ArgumentException("The string is malformed and cannot be used.")
End If
Next
If elements.Length = 2 Then
tSeconds = (60 * CInt(elements(0)) + CInt(elements(1)))
ElseIf elements.Length = 3 Then
tSeconds = (60 * CInt(elements(0)) + CInt(elements(1)))
Dim divideByString As String = "1"
For Each c As Char In elements(2)
divideByString &= "0"
Next
tSeconds += CDec(elements(2)) / CInt(divideByString)
Else
Throw New ArgumentException("The string is malformed and cannot be used.")
End If
End If
ElseIf TypeOf value Is Decimal Then
Dim d As Decimal = DirectCast(value, Decimal)
tSeconds = d
Else
Throw New ArgumentException("The type was not recognizable and cannot be used.")
End If
If tSeconds = 0 Then
Throw New ArgumentOutOfRangeException("Total Seconds", "Must be greater than zero.")
Else
_totalSeconds = tSeconds
End If
Catch ex As Exception
Throw
End Try
End Sub
Public Shared Function GetAverage(ByVal value1 As Object, _
ByVal value2 As Object) As SwimmerTime
Dim retVal As SwimmerTime = Nothing
Try
Dim st1 As SwimmerTime = New SwimmerTime(value1)
Dim st2 As SwimmerTime = New SwimmerTime(value2)
If st1 IsNot Nothing AndAlso st2 IsNot Nothing Then
Dim tempList As New List(Of Decimal)
With tempList
.Add(st1.TotalSeconds)
.Add(st2.TotalSeconds)
End With
Dim averageSeconds As Decimal = tempList.Average
retVal = New SwimmerTime(averageSeconds)
End If
Catch ex As Exception
Throw
End Try
Return retVal
End Function
Public ReadOnly Property FormattedString As String
Get
Dim ts As TimeSpan = TimeSpan.FromSeconds(_totalSeconds)
Return String.Format("{0:00}:{1:00}:{2:000}", _
ts.Minutes, _
ts.Seconds, _
ts.Milliseconds)
End Get
End Property
Public ReadOnly Property TotalSeconds As Decimal
Get
Return _totalSeconds
End Get
End Property
End Class
I'll show how to use it by example:
Option Strict On
Option Explicit On
Option Infer Off
Public Class Form1
Private Sub Form1_Load(ByVal sender As System.Object, _
ByVal e As System.EventArgs) _
Handles MyBase.Load
Try
Dim averageSwimmerTime As SwimmerTime = _
SwimmerTime.GetAverage("02:24:05", 145.3274D)
MessageBox.Show(String.Format("Formatted String: {0}{1}Actual Value: {2}", _
averageSwimmerTime.FormattedString, vbCrLf, _
averageSwimmerTime.TotalSeconds), _
"Average Swimmer Time")
Stop
Catch ex As Exception
MessageBox.Show(String.Format("An error occurred:{0}{0}{1}", _
vbCrLf, ex.Message), "Program Error", _
MessageBoxButtons.OK, MessageBoxIcon.Warning)
End Try
Stop
End Sub
End Class
An advantage here is that since it returns an instance of the class, you have access to the formatted string, and the actual decimal value.
I hope you find this helpful. :)
Still lost in code, just at a little higher level. -
How to format table columns in Forms 10g
Hi Friends,
I have payment table in the format
col1 col2
1 dell
2 HP
3 Compaq
4 Acer
i want to show this info in forms 10g
Payment has to be made tomorrow- DELL,HP,Compaq,ACERHi Francois,
I have create the from based on that data block only but it is coming sequentially, for example
Label - Payment for items tomorrow-Dell
HP
Acer
Compaq
But i need the same thing in
Payment for items tomorrow- Dell,HP,Acer,Compaq
please advice how i can make this, contect of the column should come with comma -
How to format table column values to currency?
All,
I have bound a context attribute (type - string) to a table column (TextView) which is used to display currency.
It displays the value as 123456789.00
How do I format the value as 123,456,789.00?
Is there any FM available to format?
I don't want to change the above context attribute type to CURR.
Thanks
Thruna>I don't want to change the above context attribute type to CURR.
Why not? That is the correct thing to do. That way you get formatting, sorting, even the correct decimal position and notation for different currencies and user settings.
If you must go with string for the context attribute then I still assume your source data is type CURR. When you 'move' this content into the string of the context attribute use the WRITE statement. This will format the currency variable for output. -
Hi,
I'm creating a dynamic OSMF plugin. That plugin needs to load external SWF file before sending the PLUGIN_LOAD event to the player.
How can I override the dispatch of the PLUGIN_LOAD event on my MyCustomPluginPluginInfo custom class ?
If it's not possible, the solution is to create a new MediaElement within my MyCustomPluginPluginInfo:
var mediaElement:MediaElement = mediaFactory.createMediaElement( new URLResource(null) ); //the resource is null at this point
On the player side I add that line when the plugin is loaded successfully:
//Add listener on Media Element creation
mediaFactory.addEventListener(MediaFactoryEvent.MEDIA_ELEMENT_CREATE, onMediaElementCreate);
Is it a god solution or not ?
Is there another way to do that ?
Thanks !Hello!
I'm not sure you can do it through loadPlugin stage due to an swf loader is used in factory on that moment.
As for loading an extra swf "per instance" way I'd rather do it using an element LoadTrait than try to bypass the standard factory way.
Regards! -
How to modify HTML immediatley after loading it??
I have created a web browser and I need it to have large text size as default (i.e as soon as a web page is loaded). I have written the code to do this and it works when assigned to a Jbutton.
However if use the doClick() method to invoke the button immediatley after the HTML page is loaded(using the setPage method) the HTML remains the same.
There was a suggestion that the font resizing is being done before the document is fully loaded. So I tried to synchronize the thread of my largeText method and delay execution of the doClick by using the SwingUtilities.invokeLater method.
This never worked does anybody have a solution to this problem??
Below is the code of my Display and largetext methods.
if (e.getSource().equals(largeText)){
Thread runner = new Thread() {
public synchronized void run() {
HTMLDocument doc = ((HTMLDocument) htmlMain.getDocument());
doc.setCharacterAttributes(0, htmlMain.getDocument().getLength(), doc.getStyleSheet()
.getDeclaration("font-size:24"), false);
runner.start();
SwingUtilities.invokeLater(runner);
} // End if
public void DisplayPage(String strURL) {
currentURL = strURL;
textURL.setText(strURL);
//m_btnReload.setToolTipText(strURL);
try {
setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
htmlMain.setPage(strURL);
SwingUtilities.invokeLater(new Runnable() {
public void run() {
largeText.doClick();
catch (Exception exc) {
htmlMain.setText("");
statusBar.setText("Could not open starting page. Using a blank.");
finally {
setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
} //end try
//largeText.doClick();
}You didn't set the width and height to 20. You set the
magnification to 20 percent. That's what _xscale and _yscale are:
the percentage by which an object is scaled (enlarged or reduced).
If you want to set an image's actual width and height:
image._width = 20;
image._height = 20; -
How do you close windows after loading ios7
How do you close apps/windows in ios7?
Try closing all apps in Multitask Window
1. Double tap the home button to bring up the multi-tasking view
2. Swipe up on the screenshot of the app you want to exit.
3. The app will fly off the screen -
How to format and reinstall 10.6.8 without disk
How to re-format my HD and reinstall 10.6.8 without a disk?
Can't be done. You have to either call AppleCare if you lost the original discs, call the seller of the machine if it wasn't Apple and say the discs belong to the machine and have them call AppleCare if they lost the discs. If clone your hard drive with Superduper or Carbon Copy Cloner upon purchasing a Mac with 10.6 you can always restore the clone at anytime. And before considering upgrading, note 10.7 and above lack Rosetta:
https://discussions.apple.com/docs/DOC-2465
https://discussions.apple.com/docs/DOC-3761
Macs newer than March 15, 2010 can't use the retail 10.6.3 installer, and must use the 10.6 installer that was pre bundled with them to install 10.6, if not a clone, and if pre bundled with some version of 10.6. Prebundled with 10.7 Macs can't install 10.6 unless their actual hardware refresh date preceded 10.7's July 20, 2011 release. -
How to add VIS Demo after installing APPS without it??
Hi all,
I have installed Oracle Applications wihout VIS Demo and now i want to add it. How can i do that?? Is there a script to do that?
Tks,
Paulo.Cannot be done. You must select the Vision install during the initial installation.
Loading Vision DB on existing install
Re: Loading Vision DB on existing install
Maybe you are looking for
-
In iCal, my birthdays from contacts show up 1 day before.. Also, iCal doesn't give me an edit option. Any suggestions?
-
Verizon Steals Vets Unlimited Data Plan & Veteran Discount
Whats to stop me from Filing an FCC Complaint? 1. I was promised I was qualified for Edge Program this last Nov. Waited a couple days and went to the Verizon store on my birthday to get my new Note4 and get on Edge. At this moment the sales guy said
-
How do I update ios 3.1.3 without iTunes or a computer
How do I update my ios 3.1.3 for my iPod touch 3rd generation without iTunes or a computer please help me
-
RMAN error while allocating channels
Hi We are trying to backup Oracle 11gr2 database using RMAN. The MML is provided by the vendor and we have linked the library with libobk.so. The server OS is Solaris 10 64 bit on AMD64 architecture. When we try to run backup the RMAN returns with th
-
Solaris 2.6 i386 on HP NetServer E800 - problem in detecting SCSI disk
Hi people, We have HP Netserver E800 with a 9G scsi drive attached to U2W onboard SCSI Controller. Solaris 2.6 boot disk doesn't seem to detect the 9G drive, we assume the problem is the scsi controller did not get detected at all. I found an article