What steps are required to customize a pre-existing DevExtreme JQuery DataGrid that was initially built in a cshtml file using Typescript?

I'm currently developing a web application using DevExtreme JQuery. Within the frontend, I have set up a DataGrid in a cshtml file. With DevExtreme functionality, it's possible to include an Add Button to the DataGrid that triggers a popup for inputting content into each row of the DataGrid. This is how it appears in the cshtml:

@(Html.DevExtreme().DataGrid<T>()
    .Editing(editing =>
    {
        editing.AllowAdding(true).Mode(GridEditMode.Popup).Form(c =>
        {
            c.LabelLocation(FormLabelLocation.Left);
        });
        editing.Popup(c =>
        {
            c.WrapperAttr(new { Id = "Note" });
            c.ShowTitle(true);
            c.Title("Neue Notiz");
        });

My goal now is to personalize the popup window using TypeScript. For instance, adjusting the size of the popup through TypeScript. Initially, I attempted adding a wrapper Attribute to the page and selecting the popup element, which was somewhat successful (the Popup was selected). However, I struggled to access and modify the specific DevExtreme options for the popup in TypeScript.

// gets all Elements with '.dx-popup-normal'
const $test = $('#Note').find('.dx-popup-normal') 

// selects the Popup I want
const $popup = $test[0] 

//Another Idea which didn't work
//const popupTest = DxHelpers.tryGetInstanceFromElem($test) as DevExpress.ui.dxPopup

If you have any suggestions on different approaches I could take, or if my current strategy is viable, your insights would be greatly appreciated!

Answer №1

It seems like I have a solution for your issue. Since you utilized the default mode editing in DataGrid to open the Popup, you can create your own custom popup as follows:

@(
Html.DevExtreme().Popup().ID("customPopup").ShowTitle(true).Title("Custom Title").Width("25%").Height("40%")
    .DragEnabled(false).Visible(false).ShowCloseButton(true).HideOnParentScroll(false)
    .ToolbarItems(toolBar =>
    {
        toolBar.Add().Widget(w => w.Button().Text("Create").OnClick("ShowRadioButton").Icon("plus").Type(ButtonType.Success)).Location(ToolbarItemLocation.After).Toolbar(Toolbar.Bottom);
    })
    .ContentTemplate(new TemplateName("Custom_Form_Template_In_Popup"))
)

Here is the code for the content template:

@using (Html.DevExtreme().NamedTemplate("ChooseTypeReceipt"))
{
     @(Html.DevExtreme().Form<T>().ID("customForm").ScrollingEnabled(true).LabelLocation(FormLabelLocation.Top)
 .Items(items =>
 {
     
 })
 .LabelMode(FormLabelMode.Static)
 .LabelLocation(FormLabelLocation.Left)
 )
}

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Personalizing the predefined title bar outline of the input text field

The outline color of the title in the input textbox appears differently in Google Chrome, and the bottom border line looks different as well. <input type="text" title="Please fill out this field."> https://i.stack.imgur.com/iJwPp.png To address th ...

What is the best approach for managing routes that are alike but differ in parameters, one being an integer and the

In order to manage users, I am developing a series of MVC pages. Below are the routes defined in my RouteConfig.cs: routes.MapRoute(name: "Users", url: "Users", defaults: new { controller = "Users", action = "Index" }); routes.MapRoute(name: "User Details ...

Encountering intellisense problems while declaring or utilizing TypeScript types/interfaces within Vue.js Single File Component (SFC) documents

For my Nuxt 3 project, I am developing a component and attempting to declare an interface for the component props to ensure strong typings. Here is an example: <script setup> interface Props { float: number; } const props = defineProps<Props> ...

Websites experiencing horizontal scrolling functionalities

I have noticed that in my angular project, the website becomes horizontally scrollable when I log in. This only happens after logging in, and does not occur beforehand. I'm using angular calendars and Bootstrap for styling. What could be causing this ...

Getting the first nested object within an object in Angular 8: A comprehensive guide

Looking to extract the first object from a JSON data set? In this case, we want to retrieve {"test": {"id":1, "name":"cat"}} from the following object: { "3": {"test": {"id":1, "name":"cat"}}, "4": {"test": {"id":2, "name":"dog"}}}. Keep in mind that the ...

Customizing Material UI Select for background and focus colors

I am looking to customize the appearance of the select component by changing the background color to "grey", as well as adjusting the label and border colors from blue to a different color when clicking on the select box. Can anyone assist me with this? B ...

Using multiple flatMap responses within the map operator across various functions: a guide

I've been working on a solution to connect multiple operations within a map function that follows the flatMap operator. Here's how it currently functions: flatMap( someResponse => combineLatest([ this.locator.function(someResponse, var ...

The React component fails to load due to the discrepancies in the data retrieved from various asynchronous requests

Creating a travel-related form using React with TypeScript. The initial component TravelForm utilizes multiple async-await requests within useEffect hook to update the state of the subsequent component TravelGuideFields However, the values of props a ...

Modifying the State in a Class Component

private readonly maxSizeOfDownloadedFiles: number = 1000000; state = { totalSum: this.maxSizeOfDownloadedFiles }; handleCallback = () => { this.setState({ totalSum: 12 }) alert('totalSum ' + this.state.totalSum); }; Upon executing the ...

What is the most efficient approach to handle the next state after calling setState in react with immer?

Using Typescript, React, and Immer, I have set up a state management system to save profiles with multiple options. My goal is to ensure that the active profile has the correct option data before saving it. const { updateProfileList, getProfile } = useProf ...

How to create classes in typescript without utilizing the class keyword

As someone new to TypeScript, I have a curious question about classes. In pre-ES6 JavaScript, there were no classes. So, naturally, one would think it's possible to avoid using them in TypeScript as well. However, I am struggling to figure out the c ...

What are the differences between an optional property and a non-optional property?

Let's say I am working on creating an array of type CoolObject. What would be the better approach if some objects have the property format, while others do not? // Option 1 export interface CoolObject { name: string; color: string; ...

Guide on incorporating Kendo UI typings into a TypeScript module

Currently, I am working with Kendo UI for React and TypeScript. My goal is to import the Kendo UI typings for TypeScript using a "typeof import". Following the guidance provided at https://docs.telerik.com/kendo-ui/third-party/typescript, I successfully i ...

Utilize external functions in evaluated code

After working with a TypeScript file containing the following code: import { functionTest } from './function_test' function runnerFunctionTest() { console.log("Test"); } export class Runner { run(source : string) { eva ...

Error message in Typescript: The argument type '() => () => Socket<DefaultEventsMap, DefaultEventsMap>' cannot be assigned to a parameter of type 'EffectCallback'

I am struggling to comprehend how I should specifically type constrain in order to prevent the error within my useEffect. One approach is to either cast my newSocket or specify the return value of my useEffect as any, but I am hesitant about that solution. ...

Experiencing an issue with my Angular 6.1.0 setup, using angular-cli 7 and primeng 7 - specifically encountering the error message "Initializers are not allowed in ambient context."

Issue encountered in the primeng package: While examining node_modules/primeng/components/picklist/picklist.d.ts, errors were found at line numbers 65 and 66. I have investigated the primeng package further. primeng/components/picklist/picklist.d.ts l ...

What causes the difference in behavior between using setInterval() with a named function as an argument versus using an anonymous function?

I can't seem to figure out why using the function name in setInterval is causing issues, while passing an anonymous function works perfectly fine. In the example that's not working (it's logging NaN to the console and before the first call, ...

Create a Typescript React class and define the State type as either an interface or null

When working with React and typescript, it is common to declare state types in the following manner: import * as React from "react" interface IState { someState: string } class MyClass extends React.Component<{}, IState> { state = { someSt ...

Unable to find '.file.scss' in the directory '../pages'

I am currently in the process of migrating my Ionic 3 app to version 4. However, I have encountered an issue where some pages are not recognizing the SCSS file from the TypeScript component. @Component({ selector: 'car-id', templateUrl: &apo ...

Angular is unable to access a service method through an observable subscription

Currently, I have a code for my service like this: cars() { return 'something here'; } Next, in order to retrieve the data using an observable from the component, I am attempting the following: getcars() { this.dataService.cars().subsc ...