This is a migrated thread and some comments may be shown as answers.

Data form fire command argument not getting passed to ItemCommand event handler

1 Answer 128 Views
DataForm
This is a migrated thread and some comments may be shown as answers.
YoonSoo
Top achievements
Rank 1
YoonSoo asked on 30 Jun 2017, 06:30 PM

Hi,

I have a javascript function (see below) that fires perform insert command for a data form. I am trying to pass the command argument of the button clicked to the ItemCommand event handler but somehow e.CommandArgument.ToString() tunrs out to be an empty string. Can anyone please guide me as to what i am doing wrong?

aspx:

function callSaveAll(sender,args) {                 
                        var object2 = $find("<%= OrderItemDataForm.ClientID%>");                       
                            if (object2._isItemInserted)
                                object2.fireCommand("PerformInsert", args._commandArgument);                                                                     
                }

 

.cs code:

protected void OrderItemDataForm_ItemCommand(object sender, RadDataFormCommandEventArgs e)
    {

        if (e.CommandName == "Cancel")
            ClientScript.RegisterStartupScript(Page.GetType(), "mykey", "CancelEdit();", true);


        if (e.CommandName == "PerformInsert")
        {
            if (Page.IsValid)
            {
                if (e.CommandArgument.ToString() == "SaveNew")
                {
                    saveAndNewButtonClicked = true;
                }
                else if (e.CommandArgument.ToString() == "Save")
                {
                    saveAndNewButtonClicked = false;
                }
            }
        }
    }

1 Answer, 1 is accepted

Sort by
0
Marin Bratanov
Telerik team
answered on 04 Jul 2017, 04:18 PM

Hi YoonSoo,

If this question is still valid after our discussions in your support threads, I can suggest you look into:

  • Using a standard button with its CommandArgument set. This button's CommandName can be PerformInsert. With this, the e.CommandArgument will be set to the button's property value. RadButton allows you to set the command argument via JS.
  • Having several buttons with the desired command arguments and showing/hiding the necessary ones according to your logic.
  • Using a hidden field as a flag. You can use .FindControl() from the inserted item to reach it.


Regards,

Marin Bratanov
Progress Telerik
Try our brand new, jQuery-free Angular 2 components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
Tags
DataForm
Asked by
YoonSoo
Top achievements
Rank 1
Answers by
Marin Bratanov
Telerik team
Share this question
or