- Home
- Forum
- ASP.NET MVC
- VB Grid Editing / Inserting with Dropdowns
VB Grid Editing / Inserting with Dropdowns
I'm trying to achieve a nice easy way for a user to edit a grid row. I have 2 cells which are either yes or no (stored as 1 or 0) and 1 cell for a contract ID number and a Contract Name.
I'm using Templates to display yes or no where appropriate and thats working fine.
However, I have a couple of issues :
I can't get the EDIT drop down box to show the current setting yes or no when editing, it defaults to no.
I cant get the Contract Name drop down box to show my list of items, really I only want the contract name drop down to be on Add, I don't want the user to be able to change it during edit.
when I ADD a new record, I dont get the drop down boxes.
I'm for edit I'm using
gridbuilder.ClientSideEvents(Sub(client) client.ActionBegin("begin").ActionComplete("complete"))
..
..
function complete(args) {
if (args.requestType == "beginedit")
{
var dpDataSource = [{ value: 1, text: 'Yes' }, { value: 0, text: 'No' }];
$('#SampleGridlnkActive').ejDropDownList({ dataSource: dpDataSource, selectedIndex: 1 }); // set the new dropdown
$('#SampleGridlnkDefault').ejDropDownList({ dataSource: dpDataSource, selectedIndex: 1 }); // set the new dropdown
}
and for adding i'm using
function begin(args) {
if (args.requestType == "add")
{
var dpDataSource = [{ value: 1, text: 'Yes' }, { value: 0, text: 'No' }];
var dpDataSource2 = @Html.Raw(ViewBag.listJSON);
$('#SampleGridlnkActive').ejDropDownList({ dataSource: dpDataSource, selectedIndex: 1 }); // set the new dropdown
$('#SampleGridlnkDefault').ejDropDownList({ dataSource: dpDataSource, selectedIndex: 1 }); // set the new dropdown
$('#SampleGridconContractName').ejDropDownList({ dataSource: dpDataSource2, selectedIndex: 0 }); // set the new dropdown
}
if (args.requestType == "save") {
//populate the value into conID field
$('#SampleGridconID').val = $('#SampleGridContractName').val;
}
}
if (args.requestType == "add")
{
var dpDataSource = [{ value: 1, text: 'Yes' }, { value: 0, text: 'No' }];
var dpDataSource2 = @Html.Raw(ViewBag.listJSON);
$('#SampleGridlnkActive').ejDropDownList({ dataSource: dpDataSource, selectedIndex: 1 }); // set the new dropdown
$('#SampleGridlnkDefault').ejDropDownList({ dataSource: dpDataSource, selectedIndex: 1 }); // set the new dropdown
$('#SampleGridconContractName').ejDropDownList({ dataSource: dpDataSource2, selectedIndex: 0 }); // set the new dropdown
}
if (args.requestType == "save") {
//populate the value into conID field
$('#SampleGridconID').val = $('#SampleGridContractName').val;
}
}
my class for the dpDataSource2 has Text and Value not text and value as its a selectlistitem object.
Can anyone help?
Thanks
Ross
Attachment: ToSend_88a4e2ed.zip
SIGN IN To post a reply.
1 Reply
PK
Padmavathy Kamalanathan
Syncfusion Team
August 22, 2019 01:11 PM UTC
Hi Ross,
Thanks for contacting Syncfusion Support.
QUERY1: I can't get the EDIT drop down box to show the current setting yes or no when editing, it defaults to no
From your query we understand that you are rendering a column with template, and based on the dataSource, it should be set to yes or no. But in your application, it get set to “no” irrespective of the value in dataSource. We have validated your issue. We have created a sample. It works fine. We are unable to reproduce the reported issue at our end.
Please refer the sample in the below location,
Please make sure the field value you have given in the template is correct.
Still facing the issue, please reproduce the reported issue in the sample above and share us if possible.
QUERY2: I can’t get the Contract Name drop down box to show my list of items, really I only want the contract name drop down to be on Add, I don't want the user to be able to change it during edit.
From your query we understand that you need to have dropdown for a particular column when you add new record, but while editing, the dropdown should be disabled.
We have already discussed this in our Knowledge Base help documentation.
Please refer the below help documentation,
If we have mis interpreted your queries, please get back to us.
Regards,
Padmavathy Kamalanathan
SIGN IN To post a reply.
- 1 Reply
- 2 Participants
-
RW Ross Woodward
- Aug 21, 2019 12:35 PM UTC
- Aug 22, 2019 01:11 PM UTC