Showing posts with label types. Show all posts
Showing posts with label types. Show all posts

Friday, March 23, 2012

grouping and subgrouping

Hi there

i really need help with my report:

in my report i have 32 work types and i have to group them into 16 work groups where 13 groups are made of single work type and 3 groups made of 3, 6 and 10 work types, so i can have SUM of working hours for each work group for each worker. Say:

ADMIN = SUM HRS (single work type) = no problems

VAC = SUM HRS (singel work type) = no problems

INTDBL and INTOT and INTREG = SUM HRS (group work) = problem!!!

i have no problem with the single work groups, but i can't figure out how to SUM hours for each work group with more then one work type. the other thing is: not each worker has hrs for each work type, some work types have hrs = NULL.

please help me!!!

thank you very much in advance

Is there another field for which you can refer to?Like a workgroup field?

Sunday, February 19, 2012

Gridview Sorting

I have a gridview that has AllowSorting="true" however I need to implement my own sorting because I have DateTime and Integer data types in several of the columns and I don't want an int column sorted like 1,12,2,23,3,34,4,45,5,56, etc. So, I've added SortParameterName="sortBy" and adjusted my stored procedure to accept this. For only ASC sorting, I've got

ORDER BY
CASE WHEN @.sortBy='' THEN DateCreated END,
CASE WHEN @.sortBy='DateCreated' THEN DateCreated END

and so on. However, columns can also be sorted with DESC. I tried CASE WHEN @.sortBy='DateCreated DESC' THEN DateCreated DESC END, but I get a syntax error on DESC. How can I do this?

If your select is actually returning a datatype of int, it should sort normally. If it's returning an int in a varchar, then well...|||

That's not what I was going for. I am using Atlas to do live searching/filtering of the gridview, and in order to use LIKE in my WHERE clause, I had to convert all datatypes to string. I've solved the problem by using

DECLARE @.sort AS varchar(63)
IF (RIGHT(@.sortBy,4)='DESC') BEGIN
SET @.sort=LEFT(@.sortBy,LEN(@.sortBy)-5)
END
ELSE BEGIN
SET @.sort=@.sortBy
END

with what I had before. Then in my code-behind, if "DESC" is part of the param, I start at the bottom of the table and insert rows into a new table.

If

sortBy.EndsWith("DESC")ThenDim dt2As DataTable = dt.CloneFor iAsInteger = dt.Rows.Count - 1To 0Step -1Dim rAs DataRow = dt.Rows(i)

dt2.ImportRow(r)

Next

dt = dt2

EndIf