Hello,
I would like to ask about passing the ID to Kendo grid inside the same kendo popup window. I have a popup window where it contain;
1. Input textbox to set the question.
2. Grid to set the answers (multiple choice).
(Refer Add Question.PNG)

Both are from the different tables in database And the tables are connected using QuizQuestionId inside the Answer Table.
(Refer Question.PNG) and (Refer Answer Table.PNG)


My problem is, I cannot add the answer inside because I dont have the QuizQuestionId (because I dont add the question yet into the database since both question and answer are inside the same window)
However, when I click Next button, I can save my question
My question is is there any way to solve my problem ?
Please let me know if you have any question about this.
Thank you.
This is my next button function
- function SaveAndGetNextQuestion(quizId, questionId) {
- //alert('Quiz ID: ' + quizId + '\nQuestion ID: ' + questionId);
- _url = "@Url.Action("", "QuizQUestion")",
- isCreateOperation = questionId == null;
- if (isCreateOperation)
- _url = _url + "/Create";
- else
- _url = _url + "/Edit";
- $.ajax({
- method: "POST",
- url: _url,
- data: {
- QuizId: quizId,
- Id: questionId,
- Question: $("#Question").val(),
- QuestionTypeId: $("#QuestionTypeId").val(),
- //QuestionNumber: Ques
- }
- }).done(function (response) {
- console.log("respond", response);
- if (response.IsSucceeded == true) {
- console.log(response)
- $("#questionWin").data("kendoWindow").close();
- if (isCreateOperation !== null) {
- //Ajax request to Get Guestions for Quiz
- //Open question window
- //e.preventDefault();
- var questionTemplate = kendo.template($("#NextQuestionTemplate").html());
- $.ajax({
- method: "GET",
- url: "@Url.Action("GetQuestionByQuizId", "QuizQuestion")",
- data: { QuizId: quizId }
- })
- .done(function (question) {
- var questionWnd = $("#questionWin").data("kendoWindow");
- questionData = { QuizId: quizId, Id: questionId };
- if (question == null) {
- // Create Mode
- questionWnd.content(questionTemplate(questionData));
- }
- else { // Edit Mode
- questionWnd.content(questionTemplate(questionData));
- }
- questionWnd.center().open();
- }).fail(function (msg) {
- result.html("Oops! operation is failed");
- result.show();
- })
- }
- }
- else {
- // display Error messages
- var ul = $("
- $.each(response.Message, function (index, item) {
- ul.append($("").html("" + item + ""));
- });
- var status = $(".result-status");
- status.append(ul);
- status.addClass("text-danger");
- }
- }).fail(function (msg) {
- result.html("Oops! operation is failed");
- result.show();
- });
- return questionId;
This is my view inside the popup window
Replies
Know the answer? Post it — somebody with the same question will find it here.