Task ID

17 posts, 1 answers
  1. Mohammad
    Mohammad  avatar
    11 posts
    Member since:
    Dec 2014

    Posted 30 Dec 2014 Link to this post

    How to get TaskID of selected task?

    I have seen that there is no event in Teletik RadGantt control.
  2. Answer
    Nencho
    Admin
    Nencho avatar
    1458 posts

    Posted 02 Jan 2015 Link to this post

    Hello Mohammad,

    You can hook a click event of the Tasks in the Timeline view and get the data-uid attribute of the clicked task. Then, you can loop through the tasks collection of the RadGantt using the Client API of the control and find the task with the same uid. Once identified, you can the use the get_id() function on the task and acquire the ID of the task. Please consider the following implementation, which uses the double-click event to get the ID of the task :

    <script type="text/javascript">
            function pageLoad() {
                var $ = $telerik.$;
                var gantt = $find("RadGantt1");
     
                $(".rgtTask").on("dblclick", function (e) {
                    e.stopPropagation();
                    var $element = $(e.target);
                    if (!$element.is(".rgtTask")) {
                        $element = $element.parents(".rgtTask").first();
                    }
     
                    var uid = $element.attr("data-uid");
                    var tasks = gantt.get_allTasks();
                    var task;
     
                    for (var i = 0; i < tasks.length; i++) {
                        if (tasks[i]._uid === uid) {
                            task = tasks[i];
                            break;
                        }
                    }
                    alert("DoubleClicked on task with ID : " + task.get_id());
                });
            }
        </script>


    Regards,
    Nencho
    Telerik
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Mohammad
    Mohammad  avatar
    11 posts
    Member since:
    Dec 2014

    Posted 06 Jan 2015 in reply to Nencho Link to this post

    Thanks for solution, I will try.
    Can we get it on server side?
  5. Mohammad
    Mohammad  avatar
    11 posts
    Member since:
    Dec 2014

    Posted 06 Jan 2015 in reply to Nencho Link to this post

    I used following code but did not worked.

    RadGantt:
    <telerik:RadGantt runat="server" ID="RadGantt1"
    OnDependencyInsert="RadGantt1_DependencyInsert"
    OnDependencyDelete="RadGantt1_DependencyDelete"
    OnTaskDelete="RadGantt1_TaskDelete"
    OnTaskUpdate="RadGantt1_TaskUpdate"
    OnTaskInsert="RadGantt1_TaskInsert"
    WorkWeekStart="Saturday" WorkWeekEnd="Thursday"
    SelectedView="MonthView" Width="99%" Height="475px" AutoGenerateColumns="false">



    Javascript function:
    function pageLoad() {
                var $ = $telerik.$;
                var gantt = $find("RadGantt1");
     
                $(".rgtTask").on("dblclick", function (e) {
                    e.stopPropagation();
                    var $element = $(e.target);
                    if (!$element.is(".rgtTask")) {
                        $element = $element.parents(".rgtTask").first();
                    }
     
                    var uid = $element.attr("data-uid");
                    var tasks = gantt.get_allTasks();
                    var task;
     
                    for (var i = 0; i < tasks.length; i++) {
                        if (tasks[i]._uid === uid) {
                            task = tasks[i];
                            break;
                        }
                    }
                    alert("DoubleClicked on task with ID : " + task.get_id());
                });
            }


    Function call before RadGantt1.

    <script type="text/javascript">
            pageLoad();
        </script>


    Error Message:



  6. Nencho
    Admin
    Nencho avatar
    1458 posts

    Posted 08 Jan 2015 Link to this post

    Hello Mohammad,

    Please specify what exactly is the problem? Are you encountering any javascript error? As for your question, regarding the server-side implementation - I noticed that you had submitted another identical forum ticket on the matter. I have already replied to the referenced ticket, where you can find attached a sample website, demonstrating both server and client side implementation.

    http://www.telerik.com/forums/get-task-id-on-task-select

    In addition, I would like to ask you to continue the communication in the other thread, in order to avoid duplication.

    Regards,
    Nencho
    Telerik
  7. Хосбаяр
    Хосбаяр avatar
    7 posts
    Member since:
    Jun 2013

    Posted 15 Jan 2015 Link to this post

    Trying get task id. Telerik version 2014 Q3

    Cannot read property 'get_allTasks' of null 
  8. Bozhidar
    Admin
    Bozhidar avatar
    1102 posts

    Posted 16 Jan 2015 Link to this post

    Hello,

    You've posted the same question in the following thread:
    http://www.telerik.com/forums/client-event-double-click-task

    Please continue the discussion only in that thread, to prevent unwanted clutter. I would also ask you to only post your questions in one thread (or open a new one). We monitor all active threads, and multiple posts may only cause confusion and clutter.

    Regards,
    Bozhidar
    Telerik
  9. Dan
    Dan avatar
    11 posts
    Member since:
    Dec 2015

    Posted 04 Jan in reply to Nencho Link to this post

    Nencho,

     This works fine IF the user clicks on one of the timelines... but what if I really want to detect that he selected the row from the task details view?

  10. Bozhidar
    Admin
    Bozhidar avatar
    1102 posts

    Posted 05 Jan Link to this post

    Hello,

    The table row elements inside the treelist section of the Gantt also contain the same data-uid attribute, so you can use the same approach to extract the task.

    Regards,
    Bozhidar
    Telerik
  11. Dan
    Dan avatar
    11 posts
    Member since:
    Dec 2015

    Posted 06 Jan in reply to Bozhidar Link to this post

    Thank you Bozhidar.
  12. Dan
    Dan avatar
    11 posts
    Member since:
    Dec 2015

    Posted 07 Jan Link to this post

    Another question relating to treelist view...

     How do I set the width of the treelist pane at design time? I seem to be having trouble locating the property for this.

     Thanks.

     Dan

     

  13. Bozhidar
    Admin
    Bozhidar avatar
    1102 posts

    Posted 08 Jan Link to this post

    Hello,

    You can use the ListWidth property in the markup to set the width of the TreeList.

    Regards,
    Bozhidar
    Telerik
  14. Melvin
    Melvin avatar
    14 posts
    Member since:
    Apr 2015

    Posted 07 May in reply to Bozhidar Link to this post

    Hi,

    I'm trying to get the ID of the selected task from the detail but the always return null.

    I tried to get the property as you indicate. Using the previous example . But I can not access the property data-iud that found in the TR .
    What is the problem in my code ?

    $(".radGrid").on("dblclick", function (e) { //rgtTreelist
        e.stopPropagation();
        var $element = $(e.target);
        if (!$element.is(".radGrid")) {
            $element = $element.parents(".rgtTreelistContent").first();
        }
     
        var uidtl = $element.attr("data-uid");
        var taskstl = gantt.get_allTasks();
    });

    I tried to get the property as you indicate . Using the previous example . But I can not access the data- yud property found in the TR . What is the problem in my code ?
    I tried to get the property as you indicate . Using the previous example . But I can not access the data- yud property found in the TR . What is the problem in my code ?
    I tried to get the property as you indicate . Using the previous example . But I can not access the data- yud property found in the TR . What is the problem in my code ?
  15. Bozhidar
    Admin
    Bozhidar avatar
    1102 posts

    Posted 09 May Link to this post

    Hi,

    The code is not working because the selectors are not correct. Please use the code from my previous example and it should work:
    if (!$element.is(".rgtTask")) {
        $element = $element.parents(".rgtTask").first();
    }
     
    var uid = $element.attr("data-uid");


    Regards,
    Bozhidar
    Telerik
  16. Melvin
    Melvin avatar
    14 posts
    Member since:
    Apr 2015

    Posted 09 May in reply to Bozhidar Link to this post

     Hi, 
    I made the change in the code, but I get the same result. The property return "null". I not found the way for to get value data-iud that find in property.<TR>.

    In the image you can look that I tried to get value of details gantt.

    Code

    $(".radGrid").on("dblclick", function (e) { //rgtTreelist
        e.stopPropagation();
        var $element = $(e.target);
        if (!$element.is(".rgtTask")) {
            $element = $element.parents(".rgtTask").first();
        }
     
        var uidtl = $element.attr("data-uid");
        var taskstl = gantt.get_allTasks();
    });

  17. Bozhidar
    Admin
    Bozhidar avatar
    1102 posts

    Posted 12 May Link to this post

    Hi,

    Please excuse me for the misunderstanding. Since the treelist uses a different rendering, you would need to modify the selectors a bit more. Here's a working sample:
    $telerik.$(".rgtTreelistContent tr").on("click", function(e) {
        var $element = $telerik.$(e.target);
     
        if (!$element.is("tr")) {
            $element = $element.parents("tr").first();
        }
     
        var taskUid = $element.attr("data-uid");
    });


    Regards,
    Bozhidar
    Telerik
  18. Melvin
    Melvin avatar
    14 posts
    Member since:
    Apr 2015

    Posted 12 May in reply to Bozhidar Link to this post

    Hi,

    Thanks for your help. With your example got the expected result.

Back to Top
UI for ASP.NET Ajax is Ready for VS 2017