href for only field name start with certain name or description
href for only field name start with certain name or description
issamymansour@gmail.com
Posts: 24Questions: 3Answers: 0
hi,
I want to make some column in my datatable "href " with a condition if that column name start with some thing like a word "week" or "day"
again I am using a dynamic column creating when i get my query and send back to ajax,
Regards
This question has accepted answers - jump to:
This discussion has been closed.
Answers
wrong answer, will give another one ....
You have to do something like this, but my answer is not complete as I am threatening your data instead of the column name.
Try something like this:
Well, my above example was not fully complete. What you can do is add classes to your columns and then using my code example.
Let's say give a class "week-field" to your week-columns and a class "day-field" to your day-columns.
Then you can use the same render function as above, but you have to test on the class of the column and besides that, as it looks like you do not know which columns might have these classes, change "targets" in all your columns.
I assume that at least on server-side you know what you are sending and thus are able to add classes to columns.
Thank you for help, he is my example
http://jbmruby.com.cws17.my-hosting-panel.com/datatabledemo/Weekly_Dynamic_Details_report.php?screen_name=CNN&data_type=2&name=#hashtage
what i am trying to do i have a dynamic data coming from the server with multi columns up to 52 columns. what i am doing to have a details page for each week on the page as a link as i said before.
again thanks.
Still waiting for help please, Thank you.
So basically do you not want the
null
cells to have links? Just add a test forif ( ! data )
and have itreturn '';
.Allan
Allan thank you for your response, Tester2017 give me the above solution it is not working for me, the data dynamic data coming from the server with multi columns up to 52 columns and can be one column, i need each column for the weeks to be a links but other columns no. my example show the results. i appreciate your help
Thanks.
Use the
columnsDefs.targets
option with a class name to target theweeks
columns. Give each column forweeks
a class name (such asweeks
) and usetargets: 'weeks'
.Allan
Allan, do you have an example you can give to solve my problem. I read mostly all available example in the net looking for solution but may be "i ask to much". your help is great but still no thing i can find to work with me.
Thank you.
http://live.datatables.net/lexenomi/1/edit
Allan, you are so great, your tool is great, and your support is great, Thank You.
Just last thing if you allow me, how to get the column name to send back to the server.
Do you mean the title text for the column?
Allan
allan I try that in many different way, totally not working. yes header fine or if possible the column name.
Can you link to a page showing the issue so I can help to debug it please?
Allan
here are my link example, I need to get the column name "week_29/10_4/11";
http://jbmruby.com.cws17.my-hosting-panel.com/datatabledemo/Weekly_Dynamic_Details_report.php?screen_name=___MrsZeke___&data_type=3&name=#hashtage
Thank You.
I don't actually see the code I suggested above on your page, but perhaps in this case it would be easiest to use:
Allan
Allan, you are amazing, thank you. but what about column index how to get it in
my code because the column's are totally dynamic.
in the line the number 2 can be up to 52 weeks.
$('#Dynamic thead tr th').eq(2).text()
I'd suggest using a class name:
Allan
Allan, thank you for your help, it is work fine this is what i want. Regards for all.
Allan, after i add some columns the value of the name of the column are the same for all. sorry for that but that happened, link sample:-
http://jbmruby.com.cws17.my-hosting-panel.com/datatabledemo/Daily_Dynamic_Details_report.php?screen_name=_A__Dub&data_type=3&name=word
Yes - you would need to get each cell individually. The code I gave above will get the text for the first cell it finds. That's how jQuery's
.text()
method works.It sounds like you are going to need a loop counter of some kind.
Allan
I understand what you say, and am thankful for your help but seems to be we are stack somewhere. again the code is totally dynamic the number of columns start with min. 2 can be up to 52 weeks.
in php i use a simple code that's different i know and what can be kind of loop works with my case ??????? i don't know.
Try this:
That assumes that no columns will be hidden. If they are, you'd need to adjust for that using
column.index()
.Allan
Allan, again thank you very much for your help and support keep going.