Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6658121
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T01:51:16+00:00 2026-05-26T01:51:16+00:00

I am using Datatables + jEditable to display data from my db and allow

  • 0

I am using Datatables + jEditable to display data from my db and allow user to edit each cell directly.

Currently I able to implement the inline edit and save the updated value back to database for text field and also by datepicker, however, i met problem with data which I need to allow edit by drop down.

The value I need to edit is retrieve from another db table by foreign key relationship.

 <td id="type@(item.FoodID)" class="dropdown">
     @Html.DisplayFor(modelItem => item.FoodTypes.FoodTypeName)
 </td>

I follow the guide from http://gunbladeiv.blogspot.com/2011/06/part-2-mvc-3-and-datatables-with-inline.html using action to return a list of selection by Json:

 function getFoodTypesList() {
    var list;
    $.post('GetFoodTypes', {},
        function (data) {
            list = validateJSON(data);
        },
        'json/javascript'
    );
    return list;
}

function validateJSON(x) {
    var orig = x;
    var stgify = JSON.stringify(orig);
    var splitchar = ['\\"', '\',\'', '[', ']', '\"'];
    var joinchar = ['\'', '\':\'', '', '', ''];

    for (i = 0; i < 5; i++) {
        stgify = stgify.split(splitchar[i]);
        tmp = stgify.join(joinchar[i]);
        stgify = tmp;
    }
    stgify = "{" + stgify + "}";
    var finalEdit = stgify;
    return finalEdit;
} 

Question: I do not understand what is the use of “validateJson” method but I include it just as the example

When I try to click on the field, i get a javascript error from firebug: “xxx” is not defined (xxx is the foodtypename)

If i change the view to :

<td id="type@(item.FoodID)" class="dropdown">
    @Html.DisplayFor(modelItem => item.FoodTypeID)
</td>

The error is gone but i get an empty dropdown.

Really need some help here….

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T01:51:17+00:00Added an answer on May 26, 2026 at 1:51 am

    I was able to modify the validateJson function according to my situation and its work! just in case anyone looking for the solution, i will post my method here:

    // Function to format the food type list into plugin required json format
    function validateJSON(x) {
        var orig = x;
    
        // Split and cover each array item with "" and then join with :
        for (i = 0; i < orig.length; i++) {
            var temp = orig[i].toString();
            var tempArray = temp.split(",");
            for (j = 0; j < tempArray.length; j++) {
                tempArray[j] = "\"" + tempArray[j].toString() + "\"";
            }
            orig[i] = tempArray.join(":");
        }
    
        // Original validateJson method get from website
        var stgify = JSON.stringify(orig);
        var splitchar = ['\\"', '\',\'', '[', ']', '\"'];
        var joinchar = ['\'', '\':\'', '', '', ''];
    
        for (i = 0; i < 5; i++) {
            stgify = stgify.split(splitchar[i]);
    
            tmp = stgify.join(joinchar[i]);
            stgify = tmp;
        }
    
        stgify = "{" + stgify + "}";
        var finalEdit = stgify;
        return finalEdit;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am using jquery DataTables and jEditable to allow inline editing of EACH CELL
I'm currently want to display a list of data using DataTables. And I want
I'm using DataTables ( datatables.net ) to display data from an Ajax source and
I am using jEditable to allow inline edit for my DataTables. I use a
I am using DataTables to display row data, in the last column on the
Using Flask Flask-sqlalchemy Sqlalchemy Jquery Datatables (jquery plugin) Jeditable (jquery plugin) Consider this user
I'm using datatables with the jeditable plugin, I have it setup to update directly
I am using DataTables to display some data and it works great but I
I'm currently using datatables with ajax data and I want do adjust the column
Using .Net and Oracle 11g - I've been returning dataTables from a procedure inside

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.