on 08-06-2014 2:30 PM
Hello all,
Thanks in advance for replying my post.
we have one example scenario, that we need to display table columns with week number and that based on date value in the table rows (note: the date value will see only we can bind rows on table).
Will anyone has tried attempted this situation or any instruction please suggest to us.
Thanks..
Hi All.
Thanks for your comments.
I have rearranging my question.i will get the start week and end week columns from the input field.
will it be possible to displaying those 2 records in the table with corresponding week column
(ie.. i have <valuestartdate> and <valueenddate>, should i need to find weeknumber for those two dates and loads the values to between week numbers columns on table).
My input xml like as..
Start week - 01 and end week 52 ( will get it from input field)
<entity>
<firstname>Suresh </firstname>
<lastname> Kumar </lastname>
<valuestartdate>20140101<valuestartdate>
<valueenddate>20140228</valueenddate>
<values>30</values>
<emailid>sureshkumar@mail.com</emailid>
</entity>
<entity>
<firstname>harish </firstname>
<lastname> Kumar </lastname>
<valuestartdate>20140301<valuestartdate>
<valueenddate>20140410</valueenddate>
<values>70</values>
<emailid>harishkumar@gmail.com</emailid>
</entity>
The output table like this..
Cheers
Ganesh
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Yup, could easily be done, and even a bit simpler than what I mentioned earlier:
- You know the start and end dates, so you should be able to calculate the week numbers of this date range (you could use Dennis Seah's provided formula for that)
Since that weeknumber range could be dynamic, it's best to store it in a model and use that as a column aggregation Create a table with 1-53 weeknumber columns (yes, there are years with 53 weeks)
- Since you know the weeknumbers, simply store the value for each weeknumber in your model
- Bind that to your table's row aggregation
With all these hints, you should be perfectly able to develop your requirements
The calculation of week numbers were already given by Dennis in his jsbin example :
jQuery(function() {
// this getWeek function is gotten from
Date.prototype.getWeek = function () {
var target = new Date(this.valueOf());
var dayNr = (this.getDay() + 6) % 7;
target.setDate(target.getDate() - dayNr + 3);
var firstThursday = target.valueOf();
target.setMonth(0, 1);
if (target.getDay() != 4) {
target.setMonth(0, 1 + ((4 - target.getDay()) + 7) % 7);
}
return 1 + Math.ceil((firstThursday - target) / 604800000); // 604800000 = 7 * 24 * 3600 * 1000
}
and you call it using :
var d = Date.parse(<your xml date>);
var weekNr = new Date(d).getWeek();
Hi,
Thanks a lot Robin
As i can able to finding week number of my XML dates from the getWeek(); function, now how i can map the week number values to columns weeks.
ie. if my starting week numbe values from xml is "01" and my end week number values are "09" means that how will load my <values> 30 </values> to all required week number columns.
do we have any jquery function to map all required week columns in that values ?.
Possibly you can share any of the sample sap.ui.table codes. it will more helps me.
Cheers
Ganesh
The code I'll leave up to you, since that's fairly easy
You need to take a step back, and think about how your table model should look like.
Now, since you know the columns, and the data it should represent, you already know how your model should look like:
var tableModel = [
{
firstName : "Suresh",
lastName : "Kumar",
email : "sureshkumar@mail.com",
week01 : 30,
week02 : 30,
//etc, repeat for week03 to week09
week09 : 30
},
{
firstName : "Harish",
lastName : "Kumar",
email : "harishkumar@mail.com",
week09 : 60,
week10 : 60,
//etc, repeat for week11 to week 15
week15 : 60
},
...
]
The fun part is in creating this model; you need to iterate through your XML data, and build up the array with the calculated week numbers for your start/enddates.
I'll leave it as an exercise for you how to build this table model array since that's just plain old JavaScript
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi
.
Thanks for your reply.
am giving my exact requirement here.. My xml inputs are
<firstname>Suresh </firstname>
<lastname> Kumar </lastname>
<startdate>20140101<startdate>
<enddate>20140322</enddate>
<values>30</values>
<emailid>sureshkumar@mail.com</emailid>
those start date and end date, i need to split on weekly basis and display the value(30) in all week columns.
ie. my required output should like..
Firstname Lastname Email_id week1 week2 week3 week4 week5 week6.... week12
Suresh Kumar sureshkumar@mail.com 30 30 30 30 30 30 .... 30
if possible can you share the any example will prepare table columns and rows like this.
Cheers
Ganesh
I don't quite understand your requirement:
I may sound like a broken record, but without any more details and/or code to show where your got stuck it's pretty impossible to help -
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Robin.
Thanks for your reply.
am giving my exact requirement here.. My xml inputs are
<firstname>Suresh </firstname>
<lastname> Kumar </lastname>
<startdate>20140101<startdate>
<enddate>20140322</enddate>
<values>30</values>
<emailid>sureshkumar@mail.com</emailid>
those start date and end date, i need to split on weekly basis and display the value(30) in all week columns.
ie. my required output should like..
Firstname Lastname Email_id week1 week2 week3 week4 week5 week6.... week12
Suresh Kumar sureshkumar@mail.com 30 30 30 30 30 30 .... 30
if possible can you share the any example will prepare table columns and rows like this.
Cheers
Ganesh
Just take a step back and think about what you need :
Have fun coding!
User | Count |
---|---|
93 | |
10 | |
10 | |
9 | |
9 | |
7 | |
6 | |
5 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.