I am sending list of data from action to client side. in client side i am binding jquery data table with pass data. column name is extracted because column is dynamic in my case. i got a below code which is not very clear how it is working.
My question is very basic question. see how list of data is pass from action to client side.
passed model data is captured like below way which is not clear to me
see this code first
1) we know list is kind of array then why keys are extracted from zeroth position ? Model[0] why not Model[1]
i like to know in what form data is stored into model when pass from action to client side ?
see this code again
2) in above code no ordinal position mention during extracting data. why?
3) what is Model[0] ? how it comes? because in asp.net mvc we write model like @model not Model
4) is this Model is Asp.Net MVC related model or javascript Model object ?
During keys extraction ordinal position is mentioned but in case of data extraction no ordinal position mentioned. please explain if some one understand what i am trying to know.
My main question is i have only one question that what is Model[0] here in js? is it any JavaScript related object or server side object ? if it is javascript then how server side model data comes into js model ?
please explain how above code is working at client side. thanks
My question is very basic question. see how list of data is pass from action to client side.
[HttpGet]public ActionResult Index()
{
List<UserData> data = new List<UserData>
{new UserData
{
ID = 1,
Name = "Simon"
},new UserData
{
ID = 2,
Name = "Alex"
}
};return View(data);
}
passed model data is captured like below way which is not clear to me
var keys = Object.keys(@Html.Raw(Json.Encode(Model[0])));var columns = keys.map(function (key) {return { title: key };
});var data = @Html.Raw(Json.Encode(Model));var dataSet = data.map(function (d) {returnObject.values(d);
});
console.log(columns);
console.log(dataSet);
see this code first
var keys = Object.keys(@Html.Raw(Json.Encode(Model[0])));var columns = keys.map(function (key) {return { title: key };
});
1) we know list is kind of array then why keys are extracted from zeroth position ? Model[0] why not Model[1]
i like to know in what form data is stored into model when pass from action to client side ?
see this code again
var data = @Html.Raw(Json.Encode(Model));var dataSet = data.map(function (d) {returnObject.values(d);
});
2) in above code no ordinal position mention during extracting data. why?
3) what is Model[0] ? how it comes? because in asp.net mvc we write model like @model not Model
4) is this Model is Asp.Net MVC related model or javascript Model object ?
During keys extraction ordinal position is mentioned but in case of data extraction no ordinal position mentioned. please explain if some one understand what i am trying to know.
My main question is i have only one question that what is Model[0] here in js? is it any JavaScript related object or server side object ? if it is javascript then how server side model data comes into js model ?
please explain how above code is working at client side. thanks