I have found something is not working on version 1.6.2

I have found something is not working on version 1.6.2

MundaringMundaring Posts: 34Questions: 12Answers: 1

Hi Allan,

I have been working with different version of DataTable for intranet proposes, I decided to use the latest version 1.6.2 but I found an issue referent to Left Join and options in drop down lists, where information is not loaded.

Just replacing the reference to dll 1.6.1 the same very code worked.

I have the next example using your .net project WebApiExamples.

Controller

 public class JoinController : ApiController
    {
        [Route("api/join")]
        [HttpGet]
        [HttpPost]
        public IHttpActionResult Join()
        {
            var request = HttpContext.Current.Request;
            var settings = Properties.Settings.Default;

            using (var db = new Database(settings.DbType, settings.DbConnection))
            {
                var response = new Editor(db, "users")
                    .Model<JoinModel>()
                    .Field(new Field("users.site")
                        .Options(new Options()
                            .Table("sites")
                            .Value("id")
                            .Label("name")
                        )
                        .Validator(Validation.DbValues(new ValidationOpts { Empty = false }))
                    )
                    .LeftJoin("sites", "sites.id", "=", "users.site")
                    .Process(request)
                    .Data();

                return Json(response);
            }
        }
    }

Model

public class JoinModel
    {
        public class users
        {
            public string first_name { get; set; }
            public string last_name { get; set; }
            public string phone { get; set; }
            public int site { get; set; }
        }

        public class sites
        {
            public string name { get; set; }
        }
    }

View

var editor; // use a global for the submit and return data rendering in the examples

$(document).ready(function() {
    editor = new $.fn.dataTable.Editor( {
        ajax: "/api/join",
        table: "#example",
        fields: [ {
                label: "First name:",
                name: "users.first_name"
            }, {
                label: "Last name:",
                name: "users.last_name"
            }, {
                label: "Phone #:",
                name: "users.phone"
            }, {
                label: "Site:",
                name: "users.site",
                type: "select"
            }
        ]
    } );

    // Activate an inline edit on click of a table cell
    $('#example').on( 'click', 'tbody td:not(:first-child)', function (e) {
        editor.inline( this, {
            onBlur: 'submit'
        } );
    } );

    $('#example').DataTable( {
        dom: "Bfrtip",
        ajax: {
            url: "/api/join",
            type: 'POST'
        },
        columns: [
            {
                data: null,
                defaultContent: '',
                className: 'select-checkbox',
                orderable: false
            },
            { data: "users.first_name" },
            { data: "users.last_name" },
            { data: "users.phone" },
            { data: "sites.name", editField: "users.site" }
        ],
        order: [ 1, 'asc' ],
        select: {
            style:    'os',
            selector: 'td:first-child'
        },
        buttons: [
            { extend: "create", editor: editor },
            { extend: "edit",   editor: editor },
            { extend: "remove", editor: editor }
        ]
    } );
} );
1.JPG 56.8K
2.JPG 63.9K
4.JPG 63.8K
3.JPG 58.7K

This question has an accepted answers - jump to answer

Answers

  • allanallan Posts: 54,921Questions: 1Answers: 8,611 Site admin

    I'll get back to you about this one if that is okay. I don't have a Windows machine with me at the moment to try it out.

    Regards,
    Allan

  • allanallan Posts: 54,921Questions: 1Answers: 8,611 Site admin
    Answer ✓

    Hi,

    Just to let you know, I've found the error - it is indeed a bug that was introduced with the 1.6.2 .NET libraries unfortunately. The 1.6.1 dll can be used, or I can send over an updated dll if you prefer.

    I think this issue has just dumped the 1.6.3 release up. I expect to make it in the next week.

    Regards,
    Allan

  • MundaringMundaring Posts: 34Questions: 12Answers: 1
    edited May 2017

    Thanks Allan. It is Ok, I am working with 1.6.1. I will wait for 1.6.3

    Regards,
    Wilson

This discussion has been closed.