How to achieve below requirement by using Dev Express controls - devexpress

Note: I only need to use Dev Express controls and I am using windows forms with dotnet framework 3.5
Below are my requirements
I need to display multiple check-in check-out entries with time as displayed in the screen shot and also reason specified below each check-in checkout entry.
I need to display a edit icon for each row when user clicks on the edit icon a time picker need to populate and user can modify the time and the list box time need to modify
I need to display a delete icon at the last entry when user deletes the last entry the delete icon should display to the above entry.
I have CheckinCheckOut button which need to add the data to list box in the same format which i have displayed the image
Which control should i use to complete all the above requirements?
If it is list box control for the above requirement can you please provide me a sample which satisfies all the conditions of the requirement.
Please provide a sample with the below requirement

Looks like this could be done with the GridControl. Checkin/Checkout statuses can be a column, the check-in/check-out time would be a second column and the delete/edit icon can be a third, unbound column. The reason (initial check-in, meal break, check-out etc...) could be done by binding the GridView's Row Preview Section to another field in the data source.
For instance, a simple data source such as:
public class EmployeeCheckIn
{
public enum CheckInTypes { CheckOut, CheckIn };
public CheckInTypes CheckInType { get; set; }
public DateTime CheckInTime { get; set; }
public string CheckInReason { get; set; }
}
Your GridControl could be bound to a List instance, having column 1 bound to CheckInType, column 2 bound to CheckInTime and the preview row bound to CheckInReason.
The unbound column with the edit button can make use a RepositoryItemButtonEdit control in which the text box is hidden, the ButtonKind property is set to Glyph and an "edit" image is supplied to draw the icon. Handle its ButtonClick event to invoke your edit mode.

Related

Programming Strategy for ASP.NET MVC 5 - Updating a Child or Related Records on Same Page

I am struggling a bit with strategies that allow for updating child records related to a parent record in MVC in the same view. Take for instance model classes described below.
public class Person {
public Person() {}
int personId{get;set;}
string personName{get;set}
public virtual ICollection<Phone> Phones { get; set; }
}
public class Phone {
public Phone() {}
public int PhoneId {get;set;}
public string PhoneType {get;set;}
public string Number {get;set;}
public string Ext {get;set;}
}
Providing a single page view allows for Creating,Updating,Deleting a person easily.
Adding actions that jump to views designed specifically for the phone records and then return the user to the person record is also straightforward.
What is the best strategy for displaying the related phone records for the person in the same view as the person information and allowing for the CRUD operations to be used against only the phone entities in the same view?
If the answer is that AJAX is the best approach then that is perfectly acceptable. I am looking for feedback from the community that describes what individuals have used in this type scenario in their projects that have this type of challenge.
There was one approach listed here:
http://www.codeproject.com/Articles/786085/ASP-NET-MVC-List-Editor-with-Bootstrap-Modals
That had a decent if somewhat cumbersome approach.
I have to believe that this is a much simpler problem and that I am quite literally missing the obvious.
I've done in-line editing by displaying the current phone information and having hidden inputs. When the user clicks the edit button, I toggle visibility to hide the display and show the inputs.
I've also done similar to the article. Have a modal popup to edit phone numbers, after saving the changes and closing the modal refresh the partial with the phone number list.
In either scenario I'm just submitting an ajax request and return a partial that I use to replace the div that contained the original information.
The modal dialog seems to be little more "modern".

ScaffoldColumn(false) not working because it is a FK

I am using ASP.NET Dynamic Data. The page dynamically creates a List, Edit, Details pages to display the records stored in the table in the DB.
I have the Sub Contractors in the table but I want its visibility set to false on screen.
I've tried
[HideColumnIn(PageTemplate.List)]
[Display(Name = "SubContractor Id", Order = 70)]
public object SubContractorId { get; set; }
ALSO:
[ReadOnlyColumnIn(PageTemplate.List)]
But no joy. Iv made these changes in the database.cs file.
Anyone know how can I make it disappear or remove the hyperlink from it?
EDIT:
[ScaffoldColumn(false)] usually works but because SubContractorId is a FK it seems to not take effect.
Consider the possibility of using Custom pages (List and other) for your Dynamic Data site which allows you hide specific fields.
For more information: How to: Customize the Layout of an Individual Table By Using a Custom Page Template

ASP.NET MVC cancel, not delete

I have two questions, both related to the same view: so there is view called ProductDetails which shows the details of a product.
Each product can have the status:
Available - in this case, two button are available "edit" and "remove"(which will change the status of the product to "Not available" but will not remove it from DB)
Not available - in this case, the page displays the product but no options to edit or remove are
visible.
The controller ProductsController has an action Details that shows that view.
The problem is that I don't know how to implement the two buttons (Edit and Remove) because:
Edit sends to another action method (Edit which display another view) <- this works
Remove should do (IMO) a post on the current page. In the post action, the status of the product is changed and the view is shown again.
I want both button to look like links. If I put a form for remove, then it will be displayed as a button. I would like to avoid making the button look like a link with css. Or... at least I want to use the same HTML element for both 'buttons'.
This is more an issue of displaying the elements so I have added the CSS tag to your question as some alternative answers may rely on this.
Personally I think trying to make a button look like a text link would be quite awkward, even once you turn off the border and background you have issues with lining up the text etc.
I'd say you have 2 "simple" options.
Firstly you could make the delete not post a delete request but link to a delete confirmation page (or bring up a JS modal window with your delete form and button).
Secondly you could make them both look like buttons, while you requested that it looks like a link I figured that the main point was consistency in UI than the link look specifically. You could use JQueryUI and invoke .button() on both elements, invoking JQueryUI for 1 feature is a bit overkill but it's a quick change, of course you could replicate the same idea of styling the link like the buttons but would have to spend time dealing with browser CSS issues.
the Remove link should post to the Remove action, which should in turn (after validation and DB update) redirect to the details action.
public ActionResult Details(int productId)
{
// Your current action method
return View(model);
}
public ActionResult Remove(int productId)
{
// Validate productId
// Update DB
return RedirectToAction("Details", new { productId = productId } );
}
You easily can solve your link vs button problem by using a GET instead of a POST. Don't be blinded by best practices.
Or you can use a Remove link that executes a one-liner Javascript function that posts the form:
Remove

Dynamically add different user controls

I'm working on a website that will allow instructors to report on the academic progress of students in their classes. I've got the website set up two primary pages: one with a user control that displays the classes (a GridView of basic class info with a child GridView in a template field that displays student names and checkboxes to select them -- called MiniStudents), and another with a user control that displays the selected students -- called FullStudents.
Although improbable, it's possible that an instructor could have the same student in two separate classes. I've already accounted for this in the current page setup -- the combination of student ID and class ID (class IDs change each quarter, for those thinking this will be an issue) form a unique key within the database. Recently, one of my users asked if I could break records out by classes on the page, so that instructors would be able easily recognize which class they're operating in.
So, my question is this: is it possible for me to dynamically add a column to the end of the class user control that would allow me to switch out MiniStudents for FullStudents?
If I've left out any important details or if anyone wants/needs code, please let me know.
Try this:
//Under page_load
string path;
if(condition) path = "~/MiniStudents.ascx";
else path = "~/FullStudents.ascx";
Control userControl = this.LoadControl(path);
panel1.Controls.Add(userControl);
And if you have specific properties that you want to set before the usercontrol gets rendered then make them inherit a custom usercontrol class:
public class CustomControl : UserControl
public class MiniStudents : CustomControl
public class FullStudents : CustomControl
So then you can do this:
CustomControl userControl = (CustomControl)this.LoadControl(path);
userControl.UserId = userId;
I hope this helps!
You could add both, and hide one or the other.
You could use a multiview control to control which control is visible. Though I would be concerned about your viewstate size if you are loading all these controls simulantously. It sounds like there could be a lot of data and markup on the page.

Is there an Attribute that hides a property from being bound to a gridview in asp.net?

I have an object that I set as the datasource for a gridview - this works fine, I get a nice table on the page with a column for each public property.
But - I always want to hide one of the columns (but still need it available as a public property.
I'm using a clunky hide-column-on-row-created fix for now, but am looking for a better solution, like an attribute applied to the property to hide it from databinding.
Apparently this exists in winforms:
[Browsable(false)] // this stops Type from showing up in databound controls
public string Type { get; set; }
public string Description { get; set; }
Can anyone suggest a similar solution for ASP.NET?
Update:
I marked Rex M's answer as correct, because it answers the question, but if anyone else is interested in how to do this:
What eventually worked for me was to mark the property corresponding to the column I wanted to hide as internal instead of public.
Looking at the reflected code for GridView.CreateAutoGeneratedColumns(PagedDataSource dataSource), it appears there are not any checks for attributes when it is scraping the datasource for properties. So, apparently not.

Resources