Paid-For Support

Paid-For Support

stevenfullmanstevenfullman Posts: 5Questions: 0Answers: 0
edited November 2011 in General
Hi Allan,

Firstly, although this is my first post, I've been a 'DataTabler' for ~ 2years, and absolutely love it!

I've hit a bit of a wall, though, and would like to ask about your paid support.

There's a couple of features I'd like to include in my DT, and figure it would be a wise investment to pay for your advice (/sample code ;-)).

My question is a bit silly, I suppose...but I don't know how many hours of dedicated support to purchase!

If it helps answer the question, here's what I need help with:

1) the ability to add a 'select all' selector in the thead, which (obviously) selects all the rows...in the current page (i.e. not hidden rows).
2) the ability to act on the 'select all' selector...e.g. in pseudo-code: foreach selectedrow->run this php function
3) the ability to run the same function for individually selected rows (via a checkbox)
4) the ability to re-draw the table based on the results from the php function above...
5) the ability to run a php function via a column-link, and redraw the table based on the results...or at least change the row colour for the particular row...kind of like this:

http://noblesamurai.com/blog/images/SEOTC,_SEOUC_and_SEOTCR_Return.png

I don't know if this is enough info, Allan, but I'm happy to provide more...

Warm regards,
Steve

Replies

  • allanallan Posts: 63,161Questions: 1Answers: 10,406 Site admin
    Hi Steve,

    I love the idea of being a "DataTabler"! Great to hear that you are enjoying using it!

    Its not a silly question at all - a perfectly valid one! Thanks for the details as that certainly helps me out with knowing what the issue is and estimating how long it will take. From your description, I would say 1 hour of support should cover it, although before I can put together some sample code, I think I'd need a few more details :-). For example, when you mention the select all do you mean the checkbox on the top of the first column? Then what then is clicked, it would sent information about all selected rows to the server so that it can run a PHP function (remember that DataTables is a Javascript library - so it would need to use Ajax to send information to a PHP script and run it)? What does the PHP function do when the row is selected? Is there an "unselect" function as well?

    If you just want to change row colour based on the selection, that we'd do that in Javascript, and certainly I'd be happy to put together an example showing how that can be done :-)

    Regards,
    Allan
  • stevenfullmanstevenfullman Posts: 5Questions: 0Answers: 0
    edited November 2011
    Hi Allan, and many thanks for getting back to me so swiftly!

    I realise my initial request was a bit short on detail, so hopefully this reply will help :-)

    (Apologies for the length...I figure the more I write, the easier it'll be to judge how much of your time I need to pay for!!!)

    Here's what I'm doing at the moment...

    I'm writing a keyword generation script (for SEO folks), which:

    1) Takes a 'high level' keyword (e.g. dog training),
    2) Interrogates various search engines to gather a list of long-tail keywords, and
    3) Displays the results in a DataTables table

    And yes, you're right of course, I already use an Ajax call to send the info to the PHP function. This generates a keyword array, which is then fed into DataTables.

    All this works great so far. Here's the jQuery code I use to send the request, and feed the results into DT:

    [code]

    $("form#getkeywordsform").submit(function(){
    $('#bar').css('display','block');
    $('#percentage').css('display','block');
    var keywordlist = $("textarea#keywordlist").val();
    var ksources = new Array();
    $("input[name='sources[]']").each(function() {
    if ($(this).attr('checked')) {
    ksources = ksources + $(this).val() + "+";
    }
    });
    var kdata = keywordlist;

    // Send the ajax request

    $.ajax({
    url: "../wp-content/plugins/myscript/scripts/get-keywords.php",
    type: 'GET',
    data: {getkeywords:encodeURI(kdata), getsources:encodeURI(ksources)},
    cache: false,
    success: function(data){
    $("#keywordresults").html(data);
    var oTable;
    oTable = $("#sortable").dataTable( {
    "iDisplayLength": 100,
    "sDom": 'iT<"clear">lfrtip',
    "sPaginationType": "full_numbers",
    "oTableTools": {
    "aButtons": [
    "copy",
    "print",
    {
    "sExtends": "collection",
    "sButtonText": "Save",
    "aButtons": [ "csv", "xls", "pdf" ]
    }
    ],
    "sSwfPath": "../wp-content/plugins/myscript/scripts/dataTables-1.6/media/swf/copy_cvs_xls_pdf.swf"
    },
    "aoColumns": [
    null, null, null, null,null,null
    ],
    "aaSorting": [[1, 'asc']]
    });
    $("#ksb_contentbgBanner2").show();
    $("#keywordresults").show();
    }
    });

    [/code]

    I hope that makes sense...my jQuery skills are rudimentary at best...as you can see, I'm also using the TableTools plugin.

    Anyway, here's an annotated screenshot of my DT -- a picture's worth a thousand words, etc...

    *****************************************

    http://dmo-online.com/screenshot.png

    *****************************************

    As you can see, I've added the relevant elements I'm looking for, but they don't do anything at the moment (i.e. there's no code behind the checkboxes or hyperlinks yet).

    Again...if it helps, here's how I'm generating the DT from the PHP array:

    [code]







    KEYWORD
    SOURCE

    SEOTC
    SEOUC




    <?php

    $tid = 0;
    $odd = 1;
    foreach ($ksb_keywords_clean_array as $ksb_keyword)
    {
    if (strlen($ksb_keyword['Keyword']) >= 1)
    {
    $tid +=1;
    if ( $odd == ($tid % 2))
    {
    $td_class = "gradeA";
    $td_collapse = "gradeA";
    }
    else
    {
    $td_class = "gradeX";
    $td_collapse = "gradeX";
    }

    ?>




    <?php echo $ksb_keyword['Keyword'] ?>
    <?php echo $ksb_keyword['Source'] ?>
    Analyse




    <?php
    }
    }

    ?>






    Remove Selected

    [/code]

    So, going back to my initial questions, I'd be more than happy to pay for the following advice/sample code to achieve the following:

    1) The select all checkbox in the should select all the visible rows on that page of results (i.e. not the results on page 2, 3, 4, etc)

    2) The 'remove selected' link should remove the selected rows from the DT

    3) The 'Analyse' link should fire an Ajax call to a PHP script I'm writing, which will generate results for the SEOTC & SEOUC columns. The Ajax call will pass the 'Keyword' string in the row (e.g. 'Dog Training Aberdeen) to the PHP script.

    4) The SEOTC & SEOUC columns will be 'dynamically' populated with the results in step 3)

    5) Based on the value of the returned SEOTC and SEOUC results, the row background colour will change. For instance, if the combined value of the SEOTC and SEOUC result is > 1000, the row bgcolour turns 'red'...else it turns 'green'.


    Once again, I hope this reply helps you understand where I need help...and also give you a little better indication of how much of your time I need to pay for!

    Many thanks again Allan.

    Warm regards,
    Steve

    PS Yes...let's call ourselves DataTablers!
  • allanallan Posts: 63,161Questions: 1Answers: 10,406 Site admin
    Brilliant - thanks very much for the extra detail - an hour should do it and in that hour I'll be able to build up some code and write an explanation of how it works :-)

    Regards,
    Allan
  • stevenfullmanstevenfullman Posts: 5Questions: 0Answers: 0
    edited November 2011
    Fantastic! Thanks a million Allan.

    One thing though...

    ...Let's call it 2 hours, because DT is -- and therefore you are -- *awesome*

    :-)

    (I've sent 2 x 1 hour payments via PayPal, by the way)

    If there's any more info you need from me, please shout.

    For the record, I've just upgraded my DT environment to v1.8.2

    Once again, I really appreciate your taking the time to help.

    Best wishes,
    Steve
  • allanallan Posts: 63,161Questions: 1Answers: 10,406 Site admin
    Hi Steve,

    Heh - really pleased you like DataTables :-) Thanks so much for taking up the DataTables support option - it really does help the project move forward!

    What I've done is to set up an example of what I think is needed for your table here: http://live.datatables.net/enesak/4/edit#source . To see it in action click the "Render" button in the top left. There are two dummy PHP scripts that I've used which would do the server interaction - I've included the code for them at the bottom of the Javascript - but they really just just easy echoes :-).

    If you would like any of the Javascript explained, please do ask away. I've put comments in the code which will (hopefully!) explain what is going on with the various bits. Also I've added in a couple of IDs into your generated table, in particular an id for each of the rows, so you know what to ask the server for when doing a delete or Analyse - your bit of PHP will need to be edited to add this in again.

    Again, please do just fire away with any questions :-)

    Regards,
    Allan
  • stevenfullmanstevenfullman Posts: 5Questions: 0Answers: 0
    Allan,

    You're a genius :-)

    That's absolutely brilliant...thank you so much!

    I have just one last question:

    Is it possible to change the row bgcolour based on the results returned by the PHP script?

    E.g. If the combined total of the SEOTC & SEOUC values is, say... < 100 ...make the entire row 'green', otherwise make it 'red'.

    Once again Allan, many many thanks for your help -- you've saved me literally days of head-scratching, and I'm delighted to have been able to support the DT project.

    My sincere gratitude,
    Steve
  • allanallan Posts: 63,161Questions: 1Answers: 10,406 Site admin
    Hi Steve,

    Absolutely no problem at all. I've added the following lines to the updated code here: http://live.datatables.net/enesak/5/edit

    [code]
    // Add a class to the row dependent on the sum or the return
    $(tr)
    .removeClass('bgGreen bgRed')
    .addClass( (json.SEOTC + json.SEOUC < 100) ? 'bgGreen' : 'bgRed' );
    [/code]

    which does the trick. I'm afraid the colours I've picked are a little horrible (but they make it clear what is going on!), and you might want to consider how the colours worked when a row is selected as well as green or red (possibly you could change the text colour rather than the background colour?), but that should be the basics of it :-)

    Regards,
    Allan
  • stevenfullmanstevenfullman Posts: 5Questions: 0Answers: 0
    Oh mate...that's brilliant...absolutely perfect! Exactly what I need.

    You're a diamond, Allan.

    Thanks again, you're a total pleasure to work with.

    Warm regards,
    Steve
This discussion has been closed.