Jump to content
Software FX Community

Filtering a Drop Down List


jvwiv
 Share

Recommended Posts

I have a gridfx grid that contains both a company id and item id.  I want the grid to display the item associated with the Item id, but when I am adding or updating the record, I want the modal form to contain only the item ids associated with the company that has been selected.  For instance, item id 1 and 2 are associated with company 1 and item id 3 and 4 are associated with company 2.  on the main grid, I see orders for company 1 and 2 containing all 4 items.  The description of the various items is pulled from the item master table and all is good.

When I add a new order detail record, I would like to enter the company, say # 1, and then have the item id ddl show only the items associated with company 1, which in this case will be items 1 and 2. 

Can this be done through the tool or do I need to write different pages to handle this?

Link to comment
Share on other sites

Hi,

While at this time there is no Grid event to provide that level of customization, there is a very easy way to hook into the controls of the dialog.

Choose "Configure Input Settings" smart tag at design time.  Then, choose Use Custom Template, and click Edit Template.  This will put you into template editing mode for the form's contents.  Then, just select one of the controls (preferrably the one you are speaking of), and handle its PreRender event.  There, you can filter out the unwanted dropdown list items.

Let me know how it goes.  If you have trouble, I can go deeper.

Link to comment
Share on other sites

Stephan -

I must have changed something in the html code that isn't letting me into the custom template for editing so I thought I could go in from the HTML side of things and per your instructions, just change the field information there.  On the template, could I change the datasource of the item to map to a new datasource, which has a filter associated with the current record?  If so, do you have an example I could view? 

Thx

Link to comment
Share on other sites

Go under the Grid.Editing element in the markup.  There you have access to the Updating template markup.  I urge you to use the Configure Input Settings wizard, as it generates a template for you, so you already have most of what you want there.  Otherwise you'll have to add all the FieldContainer controls, asp controls, etc. 

So the markup would resemble:

.....<Editing> 

<Updating Enabled="True" UIMode="Dialog">

<Dialog>

<ContentTemplate><asp:DropDownList runat="server" id="companyDropdown" OnPreRender="companyDropdown_prerender"></asp:DropDownList>

</ContentTemplate>

In this case, your dropdown is the "companyDropdown" control.  You see I added an event handler to the markup.  Then, in the code behind you need something like:

    protected void companyDropdown_prerender(object sender, EventArgs args)

    {

      DropDownList dropdown = ((DropDownList)sender);

      GridItem gridItem = GridItem.FindContainingItem(dropdown);

      //using gridItem.DataValues, you can filter the dropdown Items here

    }

Try that and let me know if there's anythin else you need. 

 

 

 

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

×
×
  • Create New...