DubFriend / jquery.repeater

Create a repeatable group of input elements
MIT License
389 stars 191 forks source link

setList Nested list problem #85

Closed cengmustafaalan closed 6 years ago

cengmustafaalan commented 6 years ago

i was using setList method well for a simple repeater without inner list

i am using JsonConvert.SerializeObject for convert my c# list to json. "data" is a json result from my action method.

var obj = JSON.parse(data); repeater.setList(JSON.stringify(obj));

but now in my case, i need to set list into my nested list too. but its not working.

i have Json result from my action method like

[{"Name":"Name1","TryingExamId":4,"TryingExamSectionLessons":[{"TryingExamSectionId":5,"LessonId":1,"QuestionCount":15,"DisplayOrder":1,"Id":8,"Guid":"b3d0ba9f-6a30-48e2-8e05-eb5ec61decef","CreatedOn":"2018-04-17T14:59:31.727","CreatedOnStr":"17.04.2018 - 14:59","UpdatedOn":"2018-04-17T14:59:31.727","UpdatedOnStr":"17.04.2018 - 14:59","IsDeleted":false},{"TryingExamSectionId":5,"LessonId":2,"QuestionCount":15,"DisplayOrder":2,"Id":9,"Guid":"6f2c3ac4-c186-4ea7-9180-b02a3a619344","CreatedOn":"2018-04-17T14:59:42.4","CreatedOnStr":"17.04.2018 - 14:59","UpdatedOn":"2018-04-17T14:59:42.4","UpdatedOnStr":"17.04.2018 - 14:59","IsDeleted":false}],"Id":5,"Guid":"bbaa126c-5adb-4e69-9f24-42d7d69349c4","CreatedOn":"2018-04-17T14:57:45.19","CreatedOnStr":"17.04.2018 - 14:57","UpdatedOn":"2018-04-17T14:57:45.19","UpdatedOnStr":"17.04.2018 - 14:57","IsDeleted":false},{"Name":"Name2","TryingExamId":4,"TryingExamSectionLessons":[{"TryingExamSectionId":6,"LessonId":3,"QuestionCount":15,"DisplayOrder":3,"Id":10,"Guid":"566c2d5d-a17c-4a0e-9551-301ada509d02","CreatedOn":"2018-04-17T15:00:12.46","CreatedOnStr":"17.04.2018 - 15:00","UpdatedOn":"2018-04-17T15:00:12.46","UpdatedOnStr":"17.04.2018 - 15:00","IsDeleted":false},{"TryingExamSectionId":6,"LessonId":5,"QuestionCount":15,"DisplayOrder":4,"Id":11,"Guid":"5748fdd4-7a3e-4966-b8c5-e3fc705fe857","CreatedOn":"2018-04-17T15:00:13.593","CreatedOnStr":"17.04.2018 - 15:00","UpdatedOn":"2018-04-17T15:00:13.593","UpdatedOnStr":"17.04.2018 - 15:00","IsDeleted":false},{"TryingExamSectionId":6,"LessonId":6,"QuestionCount":15,"DisplayOrder":5,"Id":12,"Guid":"b59e8e19-c973-403b-a64b-d4ddf5186d4e","CreatedOn":"2018-04-17T15:00:13.647","CreatedOnStr":"17.04.2018 - 15:00","UpdatedOn":"2018-04-17T15:00:13.647","UpdatedOnStr":"17.04.2018 - 15:00","IsDeleted":false}],"Id":6,"Guid":"2ebb080e-2006-4ccb-9385-82d2555d9fee","CreatedOn":"2018-04-17T14:59:59.53","CreatedOnStr":"17.04.2018 - 14:59","UpdatedOn":"2018-04-17T14:59:59.53","UpdatedOnStr":"17.04.2018 - 14:59","IsDeleted":false}]"

TryingExamSectionLessons are my nested list item but its not setting to repeater. outer-list setting but nested list are not.

Do you have any solution ?

vdomah commented 6 years ago

hello! have you solved this? How?

ehsanmusavi commented 6 years ago

I have the same issue :(

cengmustafaalan commented 6 years ago

hello. I was create this issue on stackoverflow. I solved this problem by myself. I was using

var $repeater = $('.repeater').repeater({

            defaultValues: {
                Id: '0'
            },
            initEmpty: true,
            show: function () {

                $(this).slideDown();
                //$(this).find('.bs-select').selectpicker('refresh');
                debugger;
            },
            repeaters: [{
                selector: '.inner-repeater',
                //initEmpty: true,
                show: function () {
                    // this method will work when only click add button
                    debugger;
                    var $this = $(this);
                    $(this).find('.bs-select').selectpicker('refresh');

                    var OrLessonPlace = $(this).find("#OrLessonPlace");
                    $(this).find('#checkbox').change(function () {
                        if ($(this).is(":checked") == true) {
                            OrLessonPlace.show();
                        }
                        else {
                            OrLessonPlace.hide();
                        }
                    });

                    $(this).slideDown();
                },
                //initEmpty: true,
            }]
        });

show funtion was not working (under repeaters). I delete "show" function and it worked for me .

You can see my View and data in here

Have a nice day.

ehsanmusavi commented 6 years ago

Not working for me, even with removing the show method.