This is a migrated thread and some comments may be shown as answers.

format columns

3 Answers 141 Views
Grid
This is a migrated thread and some comments may be shown as answers.
appdev
Top achievements
Rank 1
appdev asked on 16 Jan 2009, 05:56 PM
because i have more than 40 columns on my grid, i can't do formatting at the server side one by one. I could but i have to find out the exact position or column index if you will. So i decided to format everything in the result from database. so now one of my column has $12,000.00. when i retrieve this the grid keeps giving me an error saying that 
Input string was not in a correct format.Couldn't store <$25,659.00> in Total Column.  Expected type is Decimal. why is the grid keeps automatically assigning the type to my column instead of retrieving it just like the way it is.
here is my select statement

select '$' + convert(varchar, cast(abs(Total) as money),1))) as Total from Student

Second question is how do i format the header to have certain size and then data rows with automatic fit to the data length.

Third is can i have a header for each of the Group By Field?

please help me thanks and appreciate alot.

3 Answers, 1 is accepted

Sort by
0
appdev
Top achievements
Rank 1
answered on 16 Jan 2009, 06:06 PM
for question number 1 i have the groupbyfield that is doing gridaggregatefunction.sum which prevented it to be display because the select statement set it as a string. so if that was the case how do i do group by field have a gridaggregatefunction.sum then? thanks.
0
Sebastian
Telerik team
answered on 19 Jan 2009, 04:19 PM
Hello Duy,

Onto your questions:

  1. From your code snippet I see that you convert the value from the decimal field to nvarchar. I suppose that is the reason the modified value cannot be saved in the decimal column (since the value type is different). Please revise your code to avoid the exception.
  2. To set fixed width for your columns, merely set their HeaderStyle -> Width property to the desired value. Also verify that the TableLayout property of the master table is set to Fixed.
  3. By default the items will be grouped starting with group header as illustrated in this online demo:
    http://demos.telerik.com/aspnet-ajax/Grid/Examples/GroupBy/OutlookStyle/DefaultCS.aspx
  4. Making sure that the value returned in point 1 is of type Decimal will allow you to use sum aggregate as part of your group expression.
Best regards,
Sebastian
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
appdev
Top achievements
Rank 1
answered on 19 Jan 2009, 04:34 PM
yes i figured the problem with the format out but now i don't want to go through each record and format it but rather have that done in sql which i did. so now the format is $25,000.99. how do i get the sum of that from your grid by using gridaggregatefunction?

also i can set the header width to be a fix number but if i do that all of my data will get that value too. how do i make it so that header is width is different than data width. so say header equal to the size of whatever the header is in database and the actual column size is depend on the data length? thank you
Tags
Grid
Asked by
appdev
Top achievements
Rank 1
Answers by
appdev
Top achievements
Rank 1
Sebastian
Telerik team
Share this question
or