Is it possible not to configure grid setting on startup? - mvcgrid.net

Let say I have multiple pages, one of those is main page that simply display logo styles, text etc, the other pages uses multiple grids, do I have to configure/retrieve the data for other pages on startup even if this is not necessary?

Yes you can do that easily in any controller action method and based on whatever parameters and logic you want, and it is the same as you do in the start up configuration.
The only issue I faced while doing that is in this line:
MVCGridDefinitionTable.Add("gridName", def);
because this lines will throw an error if the grid already added and defined, and the bad news that the solution I found so far is not a good solution as you can see in this post: https://github.com/joeharrison714/MVCGrid.Net/issues/62
You can check for existing grid using
MVCGridDefinitionTable.GetDefinition method. This will throw an
exception if there is no grid and returns the grid if there is grid.
After getting the grid, set the RetrieveData property on the grid for
changing the data elements.
Something like this:
//check if grid already exist
// https://github.com/joeharrison714/MVCGrid.Net/issues/62
try
{
MVCGridDefinitionTable.GetDefinition<YOURTYPE>("gridName");
}
catch (Exception ex)
{
MVCGridDefinitionTable.Add("gridName", def);
}
*** If you got a better way please share it.

Related

How does selenide find the element inside the document and IFrame

Looking for way to pick elements with Selenide inside the document which is render using ReactJs.
I need to access xpath //h1/span[text()=' 1'] which is inside the document and Iframe. Is there a way to get that element and switch back to the main window?
Page contents look like below (Same page content in both images due to it being too long):
I'm able to succeed this using below method, Again but I got TimeoutException on time to time.
[1627896042.179][SEVERE]: Timed out receiving message from renderer: 30.000
public WebDriver getFrame(){
try {
return Wait().until(frameToBeAvailableAndSwitchToIt(iFramePth));
}catch (Exception ex){
System.out.println("error in get Frame");
ex.printStackTrace();
return null;
}
}
For that, I used the below method before calling to the above one. (Check Iframe is available)
iFramePthElement.should(Condition.appear, Duration.ofSeconds(TIME_OUT));
But even now it getting failed sometimes same error.
[1627896042.179][SEVERE]: Timed out receiving message from renderer: 30.000
To switch back to the main window, you can just do something like this:
switchTo().parentFrame();
This will take you back out of the iFrame context and back onto the main site (or parent page).
As for the Timeout issue, I think this has been covered here: https://stackoverflow.com/a/60167733/9350566

Multiple Selectors in Selenium Test

I want to test a page with responsive layout.
Some elements (like the menu) will be different depending on resolution.
how can I target them to run with the same test classes?
i'm thinking about How.CSS, using = "a.normal-link, a#responsive-link"
is this a good idea? is there a better way?
and is it possible to "inject" some kind of workaround-logic for specific occasions? (for example: if the normal login-button is not visible, try to open the responsive menu, then click the other (responsive) login-link)
I was just thinking about a try-catch block, but that feels wrong for an alternative route.
thanks
As, you need to check whether an element is visible or not, it is better to use if/else blocks, to validate the same. Sample piece of code is given below:
if(driver.findElement(<Your element>).isDisplayed()) {
// Perform your operations
} else {
// Open the button from menu item
}
Hope this helps.

iOS 9: Frame no longer set in viewWillAppear after UINavigationController pushViewController

I'm trying to solve a view placement bug that has arisen as of iOS 9. I am instantiating a view controller from a xib file (non-autolayout) and then pushing this onto my UINavigationController.
The problem is that when the view controller's viewWillAppear method is called, its frame has not yet been adjusted to the navigation controller's size and is still what was set in the xib file. It doesn't get set properly now until viewDidAppear.
This is completely screwing up my code. Does anyone know precisely what has changed that is causing this and what is the best way to handle it? I don't want to wait until viewDidAppear because this will look bad and make for a poor user experience.
I am also looking for the best fix.
My temporary one is to call the code that was in "viewDidAppear" in "viewDidLayoutSubviews". That way, my code will get called as soon as the frames are set.
But, make sure to add a boolean or something so that your code doesn't get called every time viewDidLayoutSubviews is called
-(void)viewDidLayoutSubviews{
if (didLayoutSubviews == NO){
didLayoutSubviews = YES;
// perform code that was in viewWillAppear
}
}
I occurred this issue too,
try to uncheck option "Resize View From NIB" from storyboard
Try moving the layout code from viewWillAppear to viewWillLayoutSubviews.
A little bit updated NickProvost's answer:
private var loadViewToken: dispatch_once_t = 0
override func viewDidLayoutSubviews() {
super.viewDidLayoutSubviews()
dispatch_once(&loadViewToken) { [weak self] in
if let wSelf = self {
wSelf.setupView()
}
}
}

grid panel error tooltip

I have a gridpanel and want to show a errortooltip on mouse hover as we see for textfields and combobox. Is there any inbuilt component to show this error styled tooltip for grid panel.
i am doing this to find validate based on the number of records in the grid panel.Please Help
There's nothing built-in to accomplish this, but you can still do it. Lucky for you, I had to do something like this not too long ago.
You'll need to use a column renderer. You'll also need to store the error message on the record itself, or have a way to access error messages by record. Your renderer should look something like this:
renderer: function(value, metaData, record){
if(/* record has error */){
metaData.tdCls += " x-form-invalid-field"; // Squiggly red lines
metaData.tdAttr = "data-errorqtip='This is my error message!'";
}
return value;
}
You may need to play around with styling and whatnot, but that is the gist of it. Also, you'll have to refresh your grid if the validity of your records changes, to make sure your tooltips say updated.

MVVM Light + Blend designer view error: Cannot find resource named 'Locator'.

The application runs fine but i could not see my design in the designer view.
It says Cannot find resource named 'Locator'. Obviously, i did not change anything in the code, i just did the data binding using the data binding dialog...
anyone facing the same problem?
There are two known occurrences where this can happen.
If you change to Blend before you built the application, the DLLs are not available yet and this error can be seen. Building the application solves the issue.
There is a bug in Expression Blend where, if you are placing a user control in another user control (or Window in WPF), and the inner user control uses a global resource, the global resource cannot be found. In that case you will get the error too.
Unfortunately I do not have a workaround for the second point, as it is a Blend bug. I hope we will see a resolution for that soon, but it seems to be still there in Blend 4.
What you can do is
Ignore the error when working on the outer user control. When you work on the inner user control, you should see the design time data fine (not very satisfying I know).
Use the d:DataContext to set the design time data context in Blend temporarily.
Hopefully this helps,
Laurent
I've come up with a reasonably acceptable workaround to this problem since it doesn't appear to have been fixed in Blend 4:
In the constructor for your XAML UserControl just add the resources it needs, provided you're in design mode within Blend. This may be just the Locator, or also Styles and Converters as appropriate.
public partial class OrdersControl : UserControl
{
public OrdersControl()
{
// MUST do this BEFORE InitializeComponent()
if (DesignerProperties.GetIsInDesignMode(this))
{
if (AppDomain.CurrentDomain.BaseDirectory.Contains("Blend 4"))
{
// load styles resources
ResourceDictionary rd = new ResourceDictionary();
rd.Source = new Uri(System.IO.Path.Combine(Environment.CurrentDirectory, "Resources/Styles.xaml"), UriKind.Absolute);
Resources.MergedDictionaries.Add(rd);
// load any other resources this control needs such as Converters
Resources.Add("booleanNOTConverter", new BooleanNOTConverter());
}
}
// initialize component
this.InitializeComponent();
}
There may be some edge cases, but its working OK for me in the simple cases where before I'd get a big red error symbol. I'd LOVE to see suggestions on how to better solve this problem, but this at least allows me to animate user controls that otherwise are appearing as errors.
You could also extract out the creation of resources to App.xaml.cs:
internal static void CreateStaticResourcesForDesigner(Control element)
{
if (AppDomain.CurrentDomain.BaseDirectory.Contains("Blend 4"))
{
// load styles resources
ResourceDictionary rd = new ResourceDictionary();
rd.Source = new Uri(System.IO.Path.Combine(Environment.CurrentDirectory, "Resources/Styles.xaml"), UriKind.Absolute);
element.Resources.MergedDictionaries.Add(rd);
// load any other resources this control needs
element.Resources.Add("booleanNOTConverter", new BooleanNOTConverter());
}
}
and then in the control do this BEFORE InitializeComponent():
// create local resources
if (DesignerProperties.GetIsInDesignMode(this))
{
App.CreateStaticResourcesForDesigner(this);
}
Note: At some point in time this stopped working for me and I ended up hardcoding the path to the Styles.xaml because I got frustrated trying to figure out which directory I was in.
rd.Source = new Uri(#"R:\TFS-PROJECTS\ProjectWPF\Resources\Styles.xaml", UriKind.Absolute);
I'm sure I could find the right path with 5 minutes work, but try this if you're at your wits end like I was!
In MyUserControl.xaml, instead of:
DataContext="{Binding Main, Source={StaticResource Locator}
use:
d:DataContext="{Binding Main, Source={StaticResource Locator}
where "d" has been previously defined as:
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
The reason and workaround explained here
http://blogs.msdn.com/b/unnir/archive/2009/03/31/blend-wpf-and-resource-references.aspx
Look at (b) part of the post.
I had a similar problem with a user control resource.
I added this in my usercontrol xaml code:
<UserControl.Resources>
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="pack://application:,,,/GinaControls;component/Resources/GinaControlsColors.xaml"/>
</ResourceDictionary.MergedDictionaries>
</ResourceDictionary>
</UserControl.Resources>
Where GinaControls is the namespace where the control class is declared and /Resources/GinaControlsColors.xaml is the project folder and xaml resource file name.
Hope this helps.
Just add this in your App.xaml.cs at the very beginning
here's my piece of code
[STATThread()]
static void main(){
App.Current.Resources.Add("Locator", new yournamespace.ViewModel.ViewModelLocator());
}
public App(){
main();
}
Make sure the Blend has opened the entire solution and NOT just the single project containing the views. I was right-clicking in Visual Studio and selecting Open In Expression Blend. To my surprize, Blend could not find the solution file, so it only opened the single project.
When I realized this, I launched Blend directly, pointed it to the solution file, and then Blend was able to find the ViewModelLocator in my view.

Resources