how to add data that already inserted in the database?

robi's Avatar

robi

16 May, 2012 02:31 AM

the plugins work fine when inserting new data. but i confuse when i want to add existing data from database so it ill automatically selected just like edit mode

thank you

  1. 1 Posted by rakib on 16 May, 2012 04:37 AM

    rakib's Avatar

    hi!i am also face this type of issue. i have the employee list with their availability. if the particular employee is available then it shows it names with green and in case of not it shows the name with red. i need to add prefill data in a case with this green and red options also. now the question is how can i show the green and red color in prefill data.

  2. 2 Posted by Rahul on 28 Feb, 2013 07:52 AM

    Rahul's Avatar

    Hi,

    I have the same problem as Robi.
    Data inserted properly using this plugin, but when i fetch data for edit data is not display.
    Sorry for my English.

    Please help me for this.

    Thank You all...

  3. 3 Posted by asif on 28 Feb, 2013 09:42 AM

    asif's Avatar

    i have solve that problem.
    i think this two function can help u.
    remember that draw wilson support only json formate data.
    function GetEmployeeListForEditEvent(eventId) {
    $.ajax({ type: POST", url: "BookingForm.aspx/GetAllEmployees", contentType: "application/json; charset=utf-8", dataType: "json", async: false, success: function (data, elem) { var pref = GetEmployeeListForThisEvent(eventId); $("#txtEmpMultiselect").autoSuggest(data.d, { preFill: pref.items, selectedItemProp: "EmpName", searchObjProps: "EmpName", selectedValuesProp: "EmpID", formatList: function (data, elem) { var EmpIdx = jQuery.inArray(data.EmpID, aEmpID); if (EmpIdx > -1) var aEmpAvbl = objEmp[EmpIdx].Availibility; else var aEmpAvbl = 0;

                        strToAdd = data.EmpName + '     ' + data.DisplayText;
                        var new_elem = elem.append(strToAdd);
                        if (aEmpAvbl == 1) {
                            $(new_elem).addClass("conflicted selected conflicted-selected" + EmpIdx);
                        }
                        return new_elem;
    
                    },
                    resultClick: function (data) {
                        $.each(data, function (a, b) {
                            if (typeof b.EmpID != "undefined") {
                                var EmpIdx = jQuery.inArray(b.EmpID, aEmpID);
                                //                                
                                if (EmpIdx > -1) {
                                    var aEmpAvbl = objEmp[EmpIdx].Availibility;
                                    if (aEmpAvbl == 1) {
                                        var dvMain = $('li.as-selection-item');
                                        for (i = 0; i < dvMain.length; ++i) {
                                            if (typeof dvMain.eq(i).attr('id') != "undefined")
                                                var elemID = dvMain.eq(i).attr('id');
                                        }
                                        $("#" + elemID).addClass("conflictedSelected selected");
                                    }
                                }
                            }
                        });
                    }
                });
            },
            error: function (msg) {
                alert(msg);
            }
        });
    
    }
    

    function GetEmployeeListForThisEvent(eventId) {
    var item = new Array(); $.ajax({ type: "POST", url: "BookingForm.aspx/GetEmpListForExistingEvent", data: '{ "eventId; + eventId + '"}', contentType: "application/json; charset=utf-8", dataType: "json", async: false, success: function (response) { var noOfEmp = response.d.length; for (i = 0; i < noOfEmp; i++) { var json1 = { "EmpID": response.d[i].EmpID, "EmpName": response.d[i].EmpName }; item.push(json1); } } }); var pref = { items: item }; return pref; }

  4. 4 Posted by asif on 28 Feb, 2013 09:44 AM

    asif's Avatar

    function GetEmployeeListForThisEvent(eventId) {
    var item = new Array(); $.ajax({ type: POST", url: "BookingForm.aspx/GetEmpListForExistingEvent", data: '{ "eventId; + eventId + '"}', contentType: "application/json; charset=utf-8", dataType: "json", async: false, success: function (response) { var noOfEmp = response.d.length; for (i = 0; i < noOfEmp; i++) { var json1 = { "EmpID": response.d[i].EmpID, "EmpName": response.d[i].EmpName }; item.push(json1); } } }); var pref = { items: item }; return pref; } by this function i have change the existing value.

  5. 5 Posted by Rahul on 28 Feb, 2013 09:55 AM

    Rahul's Avatar

    Hello Asif,

    Thank You for your post.
    Where to add this function? and can this functions work for you?

    I have 1 form to submit data of publication. I used autosuggest plugin to add the authors of publication which comes from DB.
    Now data is added properly. But when i fetch the data for edit, author name are not display as display in add mode.
    Please suggest me.

    Thank You

  6. 6 Posted by asif on 28 Feb, 2013 10:10 AM

    asif's Avatar

    U can add this function after edit event occurs to load all the data again. Look here i retrive to data.EMpID and EMpname.And fetch them into the box.I just used jSON array. And call that in the main function

Reply to this discussion

Internal reply

Formatting help / Preview (switch to plain text) No formatting (switch to Markdown)

Attaching KB article:

»

Attached Files

You can attach files up to 10MB

If you don't have an account yet, we need to confirm you're human and not a machine trying to post spam.

Keyboard shortcuts

Generic

? Show this help
ESC Blurs the current field

Comment Form

r Focus the comment reply box
^ + ↩ Submit the comment

You can use Command ⌘ instead of Control ^ on Mac