Add new Row with html input type
Add new Row with html input type
nightsky_ting
Posts: 17Questions: 4Answers: 0
Hi,
How to add new row with textbox and combo box?
For eg, first column will display an combox box to allow user to select and second column will be text box to allow user fill up.
Thanks
This discussion has been closed.
Answers
Please supply more detail.
Do you mean how to add this row dynamically or on initialisation?
Are you using DataTables' Editor (in which case you should apply the necessary field types)?
Hi ,
what I mean is how to add row dynamically.
This is how I do, I am not very sure correct or not.
HTML
Do you mean the
AddRows()
function? If so, can you show us that function?Allan
Currently , I just insert value in by hardcode.
function AddRows()
{
But This function also cause error.
I have attached the following error.
You are adding an object, but your DataTable is configured to use arrays. See this section of the manual to understand the difference between the two.
Allan
Hi,
Actually I would like to add
@Html.DropDownListFor(m => r.ItemArray[0],
Model.OffsetType.Select(x => new SelectListItem() { Value = x, Text = x, Selected = (x == r.ItemArray[0].ToString()) }).ToList(),
new { @id="offsetType", @name="offsetType"})
Is it possible?
Thanks
Does that return an object or array into your JSON?
Allan
it return List of string.
Sorry to keep asking questions - I'm trying to get enough information to be able to answer your question. If you have a link to the page that would enable me to debug it directly.
If that isn't possible, could you show me the resulting information that is sent to the browser from your above code. Also a debug trace would be useful.
Allan
http://debug.datatables.net/ohifuj (debug trace)
In Img2.jpg shows the GUI. If the user click on the add new row, it should
display first column combo box then second row text box and so on
To get the date in the combo box
string[] offsetType = SetupWeb.Properties.Settings.Default.OffsetType.Split('|');
OH - I see!! Thanks for the picture - that's cleared things up.
Ok, what you would need to do in that case, since you want to include information that is only available on the server (i.e. your ASP code - I presume its ASP?) you would need to make a call to the server to get that information - probably with
$.ajax
.Have it request a script that will generate the HTML you need for the row and then you can inject it into the table using
row.add()
.Allan
hi do u have sample?
I am using c#.
Thanks
Not of that specifically I'm afraid.
Allan
ok thanks.