¿Como formulo los data atributos de manera dinamica en js o jquery utilizando una funcion personalizada para reenderizar el datatable?

La cuestion es la siguiente: Tengo un datatable personalizado llenado con multiples checks que se dibuja dinamicamente con la llamada al api, el problema es que necesito que cada columna tenga un data-atributo(data-modulo), es una tabla que autoriza los permisos que tiene cada usuario pero para poder inicializarlos todos segun los permisos autorizados de cada usuario y para eso necesito que cada columna debajo de los modulos tenga los siguientes atributos les muestro:

 const columnas = [                         { "data":'id', "title":'Departamento', "targets":0 },                         { "data":'correo_electronico', "title":'Correo Electrónico', "visible":false, "targets":1 },                          { "data":'nombre', "title":'Nombre', "targets":2 },                         { "data":'check1', "className":'text-center', "targets":3, "bSortable":false, "createdCell":function(td){ $  (td).attr({"data-modulo":5,"data-lectura":1}) } },                         { "data":'check2', "className":'text-center', "targets":4, "bSortable":false, "createdCell":function(td){ $  (td).attr({"data-modulo":5,"data-escritura":1}) } },                         { "data":'check3', "className":'text-center', "targets":5, "bSortable":false, "createdCell":function(td){ $  (td).attr({"data-modulo":4,"data-lectura":1}) } },                         { "data":'check4', "className":'text-center', "targets":6, "bSortable":false, "createdCell":function(td){ $  (td).attr({"data-modulo":4,"data-escritura":1}) } },                         { "data":'check5', "className":'text-center', "targets":7, "bSortable":false, "createdCell":function(td){ $  (td).attr({"data-modulo":3,"data-lectura":1}) } },                         { "data":'check6', "className":'text-center', "targets":8, "bSortable":false, "createdCell":function(td){ $  (td).attr({"data-modulo":3,"data-escritura":1}) } },                         { "data":'check7', "className":'text-center', "targets":9, "bSortable":false, "createdCell":function(td){ $  (td).attr({"data-modulo":2,"data-lectura":1}) } },                         { "data":'check8', "className":'text-center', "targets":10, "bSortable":false, "createdCell":function(td){ $  (td).attr({"data-modulo":2,"data-escritura":1}) } },                         { "data":'check9', "className":'text-center', "targets":11, "bSortable":false, "createdCell":function(td){ $  (td).attr({"data-modulo":1,"data-lectura":1}) } },                         { "data":'check10', "className":'text-center', "targets":12, "bSortable":false, "createdCell":function(td){ $  (td).attr({"data-modulo":1,"data-escritura":1}) } },                         { "data":'check11', "className":'text-center', "targets":13, "bSortable":false },                     ];   

La cuestion estaria que sea dinamica la parte del createdCell para que la columna par que es permiso de lectura me se agregue el data-lectura y en la columna impar se agregue el data-escritura y a su vez se agregue el data-modulo pero en decremento cada dos columnas, es decir, que pasa las primeras dos columnas de lectura y escritura se agregue 4, despues en la siguiente se agregue 4 y despues 3 asi sucesivamente cada 2 columnas hasta que llegue a 1 solamente.

Lo intente hacer de la siguiente manera:

  let  data_attr = (td,cellData,rowData,rowIndex,colIndex) =>{                                                            if (rowData.id === 1) {                         for (let i = a(modulos_id.length); i >= 1; i--) {                             for (let j = 1; j <= 2; j++) {                                 if (colIndex % 2 === 0)                                      $  (td).attr({"data-modulo":i,"data-lectura":1});                                 else                                      $  (td).attr({'data-modulo':i,"data-escritura":1});                                    }                              }                         }                                                   }  //Declaramos las columnas y asignamos los valores junto con cada conjunto de checks en sus respectivos permisos                     const columnas = [                         { "data":'id', "title":'Departamento', "targets":0 },                         { "data":'correo_electronico', "title":'Correo Electr&oacute;nico', "visible":false, "targets":1 },                          { "data":'nombre', "title":'Nombre', "targets":2 },                         { "data":'check1', "className":'text-center', "targets":3, "bSortable":false, "createdCell":data_attr },                         { "data":'check2', "className":'text-center', "targets":4, "bSortable":false, "createdCell":data_attr },                         { "data":'check3', "className":'text-center', "targets":5, "bSortable":false, "createdCell":data_attr },                         { "data":'check4', "className":'text-center', "targets":6, "bSortable":false, "createdCell":data_attr },                         { "data":'check5', "className":'text-center', "targets":7, "bSortable":false, "createdCell":data_attr },                         { "data":'check6', "className":'text-center', "targets":8, "bSortable":false, "createdCell":data_attr },                         { "data":'check7', "className":'text-center', "targets":9, "bSortable":false, "createdCell":data_attr },                         { "data":'check8', "className":'text-center', "targets":10, "bSortable":false, "createdCell":data_attr },                         { "data":'check9', "className":'text-center', "targets":11, "bSortable":false, "createdCell":data_attr },                         { "data":'check10', "className":'text-center', "targets":12, "bSortable":false, "createdCell":data_attr },                         { "data":'check11', "className":'text-center', "targets":13, "bSortable":false },                     ];   

Sin embargo en los lopps al momento que se ejecuta la funcion no me lo deja como en el primer fragmento de codigo si no mas bn todo funciona pero estoy atorado con el data-modulo para que me decremente como espero y en realidad cuando entra ya al reendereado del datatable se queda en un solo valor por ejemplo 1 y se lo agrega a todas las columnas de de los permisos en todas las filas de los usuarios

Data Entry, copy paste and writing service for $5

I am good at Data Entry in Excel and google spreadsheets directly from pdf pages or through web researching. I have done a wide range of Web Research, Data Entry, Excel, Google Docs and Data Conversion work for large companies and small businesses. So, I will do these type of works with great care and best output will be delivered. -Data input in Google Documents or Spreadsheets -Typing -MS excel spreadsheets, word documents, power point presentations -Data transcribing from PDF, image, scan. I can guarantee 100% customer satisfaction with all my work deliverable, on time delivery with best Quality. Hire me and you will never be disappointed.

by: Manojkhatri2925
Created: —
Category: Data Entry
Viewed: 141


How can I use WHOIS data for security purposes?

I’m a small business owner and it’s my first time giving a WHOIS database download service a try. I’ve seen what details are shown in the records and I heard that WHOIS information can be used not only to learn domains owners’ contact information but for security purposes as well. So I was wondering how exactly it can be used? And are there any other use cases for it?

How to edit or update the ordered item data in magento 2

I want to edit some data’s of ordered items like weight, price and some more.

For that, I got the ordered item collection for the specific order.

$  objectManager = \Magento\Framework\App\ObjectManager::getInstance(); $  orderItemId = '3'; $  orderItem = $  objectManager->create('\Magento\Sales\Api\OrderItemRepositoryInterface')->get($  orderItemId); $  orderItems = $  orderItem->getData() 

So $ orderItems has the ordered item collection.

And then I have tried to edit the ordered items like below.

foreach ( $  orderItems->getData() as $  val ) {     $  val->setWeight(1)->save(); } 

But the weight not gets updated.

Full Code:

$  orderId = $  _GET['id']; $  objectManager = \Magento\Framework\App\ObjectManager::getInstance(); $  order = $  objectManager->create('Magento\Sales\Api\Data\OrderInterface')->load($  orderId);  // Edit the order items data foreach ($  order->getAllItems() as $  key => $  value) {     $  orderItemId = $  value->getData('item_id');     $  orderItem = $  objectManager->create('\Magento\Sales\Api\OrderItemRepositoryInterface')->get($  orderItemId);     $  orderItems = $  orderItem->getData();     foreach ( $  orderItems as $  val ) {         $  val->setWeight(1)->save();     } } $  orderResourceModel->save($  order); 

I’ve just referred this link here. But I’m not having a clear idea about the orderquote.

I’m using magento 2.3 version.

Please help me. I am a novice in magento and I am stuck at this point. Thank you in advance!!

Propagating Data to multiple ViewModels – C#

I’m a bit new to MVVM, but here’s my dilemma:

  1. I have a model (or models, but let’s keep it simple)
  2. I want to show that model data on multiple different views.
  3. Ok, so ViewModel for each view gets created
  4. UserControls get created (my views)
  5. each Usercontrol gets a ViewModel

Here’s my question: What/where/how do I handle propagating this model to each viewmodel?

This is desktop dev, not web dev, so I’m getting stuck on the idea of making sure that the model is in each viewmodel. Normally I handle this by having a controller/parent class propagate down the information to each ViewModel, but I’m starting to get into a more complex application where it’s not one model that I need to propagate, but multiple models and viewmodels that might need to call services that would need that info as well, and I’m getting a bit confused as to how exactly the best practice is to proceed.

Just to be thorough, here’s a quick example:

View1, View2, View3, and View4 all exist.

View1 and View2 need models M1, M2, and M3 View3 needs models M1, M3, and M4 View4 needs models M2, M3, M4, and M5

Each view now has it’s own corresponding ViewModel, VM1-4.

How do I create and propagate M1-5 to the corresponding VMs?

Data Models: Reference vs Value Semantics vs Immutable

As I see it (please correct my assumptions if necessary), there are (at least) the following three approaches for a data model in a document-based app:

  1. Reference semantics. The traditional data model design. An item in your data model is mutable. If you mutate, any other reference to that item will see the update.
  2. Value semantics. Items in your data model are mutable. If you mutate, only you will see the update.
  3. Immutable. Items in your data model are not mutable. To change your data model, you must build a new data model.

What are the implications of each approach in terms of memory usage, and how undo/redo works?

What criteria should be used in choosing the approach for a non-trivial app? If it helps in narrowing the focus, we can assume the app is a vector-graphics editing app, which can contain nested hierarchies of shapes, and lots of user-authored data.